private void FileDownLoad(string filename)
{
string destFileName = filename;
//destFileName = Server.MapPath("./") + destFileName;
destFileName = Server.UrlDecode(destFileName);
if (File.Exists(destFileName))
{
FileInfo fi = new FileInfo(filename);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = true;
Response.Charset = "GB2312";
//添加头信息,为 "文件下载/另存为 "对话框指定默认文件名
Response.AppendHeader("Content-Disposition", "attachment;filename="
+ HttpUtility.UrlEncode(Path.GetFileName(destFileName),
System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "text/plain";
Response.Filter.Close();
Response.WriteFile(destFileName);
Response.Flush();
Response.End();
}
else
{
Response.Write("");
}
}
.net直接有一个控件。FileUpload拉到项目上,然后1楼的代码很完善了,可以照做