[求助]文件下载问题(虚拟路径)
private void FileDownload(string fName, string path){
long lngFileSize;
byte[] bytBuffer;
int iReading;
string sFileName = Server.MapPath(path + fName);
Stream outStream = Response.OutputStream;
Response.ContentType="application/octet-stream";
Response.AppendHeader("Connection","keep-alive");
Response.AppendHeader("Content-Disposition"," attachment; filename = "+fName );
FileStream fStream = new FileStream(sFileName,FileMode.OpenOrCreate,FileAccess.Read);
lngFileSize = fStream.Length;
bytBuffer = new byte[(int)lngFileSize];
while((iReading=fStream.Read(bytBuffer,0,(int)lngFileSize)) > 0)
{
outStream.Write(bytBuffer,0,iReading);
}
fStream.Close();
outStream.Close();
}
MapPath“E:\计算公式\public\G1TCA.txt”的路径无效。应为虚拟路径。
请问哪位有c# 的文件下载的代码啊?
帮帮忙啊!