在windows server 2003 sp1中使用下面代码
if ( File.Exists(destFileName) ) //判断文件是否存在
{
FileInfo fi = new FileInfo(destFileName);
Response.Clear();
Response.ClearHeaders();
Response.Charset = "utf-8s";
Response.Buffer = false;
Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(Path.GetFileName(destFileName),System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length",fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(destFileName);
Response.Flush();
Response.End();
}
下载文件,程序为什么会关闭