FileStream:从文件的最后一行删除“ NULL”

时间:2019-04-22 13:36:01

标签: c# asp.net-mvc

我想知道为什么从Web服务器下载文件后(* .hex文件的最后一行不包含任何内容,它只是一个空行)为什么将新文件的最后一行保存为NULL会增加我的* .hex文件的大小:

        byte[] buffer = null;

        using (FileStream fs = new FileStream("Drive of the server: //download.hex", FileMode.Open, FileAccess.Read))
        {
            buffer = new byte[fs.Length];       
            fs.Read(buffer, 0, (int)fs.Length);
        }

        var cd = new System.Net.Mime.ContentDisposition
        {
            FileName = "Fresh_copy_of_the_file" + ".hex",
            Inline = false,
        };

        Response.AppendHeader("Content-Disposition", cd.ToString());

        return File(buffer, "application/octet-stream");

enter image description here

0 个答案:

没有答案