string strFilename_org=@"B:\1402\tmuninst1402.ini";System.IO.FileInfo file = new System.IO.FileInfo(strFilename_org);
Response.Clear();
string filename=@"e:\bak\"+strFilename_org;
filename=HttpUtility.UrlEncode(filename).Replace('+',' ');
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType ="text/html";
Response.WriteFile(file.FullName);
Response.End();
Page.RegisterStartupScript("alert","<script language='javascript'> alert('文件成功下载!!')</script>");
Response.Clear();
string filename=@"e:\bak\"+strFilename_org;
filename=HttpUtility.UrlEncode(filename).Replace('+',' ');
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType ="text/html";
Response.WriteFile(file.FullName);
Response.End();
Page.RegisterStartupScript("alert","<script language='javascript'> alert('文件成功下载!!')</script>");
解决方案 »
- VS2005中自带的sql数据库功能与SQL server2005的区别?
- 高手给个思路,要不就给个小案例,先谢了
- 页面传递参数的问题
- asp.net 中的附件上传问题
- 高手帮修改鼠标经过图片 先清晰后放大 代码.谢谢先 ~~
- 谁有GridView+Sql2000分页的例子。谢谢了,给分
- 请问这个莫名其妙的错误是什么意思?
- 求asp.net+vb.net 文件下载的完整代码
- 将文件路径保存到数据库中,如何在客户端打开并显示?在线等
- 对于Directory,File,Stream*,Text*类使用的菜鸟级疑惑,请各位解惑,多谢!
- asp.net中怎样模拟用户的点击button事件
- ocx里如何访问<param>里的name和value的值
Response.ContentType = strContentType;
Response.AppendHeader("content-disposition","attachment;filename="+strFileName);
Response.WriteFile(Request.PhysicalApplicationPath+strExportFileName);
System.IO.File.Delete(Request.PhysicalApplicationPath+strExportFileName); // delete the exported file from the disk
Response.Close();
{
if(!IsPostback)
{
try
{
//把你的读文件等代码写到这里
}
catch
{
Response.End();
}
}
}