
public void Open(string FileName) |
{ |
string FullFileName = ""; |
try |
{ |
FullFileName = FileName; //文件物理路径 |
FileInfo DownloadFile = new FileInfo(FullFileName);//文件流 |
if (DownloadFile.Exists) |
{ |
Response.Clear(); |
Response.ClearHeaders(); |
Response.Buffer = false; |
Response.ContentType = "application/octet-stream"; |
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));//filename设置文件的名称 |
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString()); |
Response.WriteFile(DownloadFile.FullName); |
Response.Flush(); |
Response.End(); |
} |
} |
catch |
{ |
//打开时异常了 |
} |
} |



