我使用下面的代碼來打開一個文件。當我提示打開/保存文件時,它顯示文件來自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