标题:[求助]文件下载问题(虚拟路径)
只看楼主
joan_1027
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-7-28
 问题点数:0 回复次数:1 
[求助]文件下载问题(虚拟路径)
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# 的文件下载的代码啊?

帮帮忙啊!



搜索更多相关主题的帖子: 路径 Response string 文件 
2006-08-03 09:06
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
得分:0 
Server.MapPath(path + fName)
直接改為"E:\计算公式\public\"+fName;

[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-08-03 09:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-81780-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014648 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved