asp.net下载文件
来源:互联网 发布:mysql 字符长度函数 编辑:程序博客网 时间:2024/05/23 01:13
try
{
string resourceurl=".//路径//文件名.扩展名";
int i = resourceurl.LastIndexOf('\\');
string filename=resourceurl.Substring(i + 1);
string FullFileName = Server.MapPath(resourceurl);
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-Disposition", "attachment;filename=" + filename);
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
else
{
ClientScript.RegisterStartupScript(GetType(),"alert","alert('文件不存在!')",true);
}
}
catch
{
throw;
}
{
string resourceurl=".//路径//文件名.扩展名";
int i = resourceurl.LastIndexOf('\\');
string filename=resourceurl.Substring(i + 1);
string FullFileName = Server.MapPath(resourceurl);
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-Disposition", "attachment;filename=" + filename);
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
else
{
ClientScript.RegisterStartupScript(GetType(),"alert","alert('文件不存在!')",true);
}
}
catch
{
throw;
}
- 下载文件 asp.net
- ASP.NET文件下载
- asp.net 文件下载
- asp.net 下载文件
- Asp.net 下载文件
- asp.net文件下载
- Asp.net 文件下载
- ASP.NET 文件下载
- ASP.NET 下载文件
- asp.net下载文件
- Asp.Net 文件下载
- ASP.NET 文件下载
- ASP.NET下载文件
- ASP.NET下载文件
- asp.net下载文件
- ASP.NET文件下载
- asp.net下载文件
- ASP.NET 文件下载
- 如何查找SAP的旧TCODE对应新的TCODE
- HDU 1301 Doubles
- 百度地图定位当前城市并设置中心点
- 使用xml和java代码混合控制UI界面
- 不遗憾的故事里,伴随着一颗笨笨的专心
- asp.net下载文件
- HTML Embed 用法
- flex用字节流作背景图片
- c# LINQ查询语句
- xcode开发问题收集
- 操作Android手机路由表
- Rosmin--折腾USB Host Shield的日子
- C++获取mac地址
- zipalign方法