实现下载功能

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));
//上面用了URL编码,否则中文的文件名会显示乱码
 Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
 Response.WriteFile(DownloadFIle.FullName);
 Response.Flush();
 Response.End();
}
posted @ 2006-07-10 11:24  pensir  阅读(353)  评论(0编辑  收藏  举报