[csharp] string FullFileName = "";
try
{
string FileName = "拓鵬雲信接口文檔 v2.0.pdf";
FullFileName = Server.MapPath(FileName);
//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.ASCII));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
else
{
//文件不存在
}
}
catch(Exception ex)
{
//打開時異常了
}
string FullFileName = "";
try
{
string FileName = "拓鵬雲信接口文檔 v2.0.pdf";
FullFileName = Server.MapPath(FileName);
//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.ASCII));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
else
{
//文件不存在
}
}
catch(Exception ex)
{
//打開時異常了
}