传递的参数是:
`C:\Licenses\testfolder\PERSONAL-Wednesday 04 July-0405.txt`,`c2license.txt`
功能是:
/// <summary>
/// Starts serving the download
/// </summary>
public static void InitStoreDownload(string filePath, string serveFileName)
{
// Get size of file
var f = new FileInfo(filePath);
var fileSize = f.Length;
var extension = f.Extension;
var context = HttpContext.Current;
context.Response.Clear();
context.Response.Buffer = false;
// Correct mime type
if (extension.Equals(".zip", StringComparison.CurrentCultureIgnoreCase))
context.Response.ContentType = "application/octet-stream";
else if (extension.Equals(".txt", StringComparison.CurrentCultureIgnoreCase))
{
context.Response.ContentType = "text/plain";
}
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + serveFileName);
context.Response.AddHeader("Content-Length", fileSize.ToString());
context.Response.TransmitFile(filePath);
context.Response.Close();
context.Response.End();
}
服务器上的C:\Licenses\testfolder\PERSONAL-Wednesday 04 July-0405.txt
文件长 475 字节。
使用此脚本获取时下载的文件为 474 字节,文件末尾缺少一个字节。(最后一个字节是句号,存在于服务器上的文件中,但通过此函数下载时不存在)。这会导致文件无效。
我们正在挠头试图找出为什么缺少一个字节,有人可以帮忙吗?