我使用下面的代码来打开一个文件。当我提示打开/保存文件时,它显示文件来自localhost,但该文件可能位于网络驱动器中。有没有什么办法可以替换本地主机的实际位置?如何用其实际路径替换localhost?
byte[] bts = System.IO.File.ReadAllBytes(fileName);
Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Content-Type", "Application/octect-stream");
Response.AddHeader("Content-Length", bts.Length.ToString());
Response.AddHeader("Content-Disposition", "attachment; filename=" + ((LinkButton)sender).Text);
Response.BinaryWrite(bts);
Response.Flush();
Response.End();
编辑:((LinkButton的)发送器)。文本)是不带路径的文件名。例如,文件的实际位置是Y:\ SPR_Upload,Y是映射到C $(\ m6300-7)的网络驱动器。当我点击文件时,系统提示我是否要从本地打开或保存XXX(24.1KB)?我想用m6300-7替换localhost。我怎么做?
对不起,我的不清楚。请看我的新编辑。 – GLP 2012-01-09 21:17:57
@GaolaiPeng回答更新 – 2012-01-11 16:15:10
谢谢。我明白了。猜猜你不允许改变它。 – GLP 2012-01-11 20:51:25