private void downLoad(string filenamed)
{
string path = Server.MapPath("attPath/") + filenamed;
FileInfo fi = new FileInfo(path);
if (fi.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(filenamed));
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream;charset=gb2321";
Response.WriteFile(fi.FullName);
Response.Flush();
Response.Close();
Response.End();
}
}
.net常用下载文件代码
最新推荐文章于 2024-10-07 18:03:22 发布