C# 4.0 文件从app_数据文件夹下载,但格式已损坏

C# 4.0 文件从app_数据文件夹下载,但格式已损坏,c#-4.0,download,asp.net-4.0,app-data,C# 4.0,Download,Asp.net 4.0,App Data,我的web应用程序将文件.png、.bmp、.jpg、.jpeg、.jpe、.jfif、.gif、.tif、.tiff、.doc、.docx、.pdf、.xls、.xlsx存储在app_data/upload文件夹中。它存储在实时服务器上,就像存储在本地系统上一样。但当尝试下载时,它会以相同的文件大小下载,但格式已损坏 下面是从live server下载文件的代码 string strURL = "~/App_Data/Upload/" + fileRepository.FileName; We

我的web应用程序将文件.png、.bmp、.jpg、.jpeg、.jpe、.jfif、.gif、.tif、.tiff、.doc、.docx、.pdf、.xls、.xlsx存储在app_data/upload文件夹中。它存储在实时服务器上,就像存储在本地系统上一样。但当尝试下载时,它会以相同的文件大小下载,但格式已损坏

下面是从live server下载文件的代码

string strURL = "~/App_Data/Upload/" + fileRepository.FileName;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.ContentType = "application/octet-stream";
response.AppendHeader("Content-Disposition", "attachment;filename=\"" + fileRepository.FileName + "\"");
byte[] data = req.DownloadData(Server.MapPath(strURL));
response.BinaryWrite(data);
response.TransmitFile(Server.MapPath(strURL));
FileRespository.DownloadCount(Convert.ToString(_fileID));
response.End();
下载word文件时,请查看附件中的图片。 请帮帮我。

将文件读取为块/缓冲区,而不是传输文件