asp.net下载代码

Posted on 2006-09-25 17:33  joinsky  阅读(3342)  评论(5编辑  收藏  举报
private void FileDownload(string FullFileName)
  {
   FileInfo DownloadFile = new FileInfo(FullFileName);
   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));
            Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
   Response.WriteFile(DownloadFile.FullName);
   Response.Flush();
   Response.End();
  }

Copyright © 2024 joinsky
Powered by .NET 8.0 on Kubernetes