日期:2014-05-18 浏览次数:21019 次
//文件下载功能 FileInfo file = new System.IO.FileInfo(Server.MapPath(path)); if (File.Exists(Server.MapPath(path))) { string name = Path.GetFileName(Server.MapPath(path)); //存在文件 Response.Clear(); Response.Buffer = false; //通知浏览器下载文件而不是打开 Response.ContentType = "application/octet-stream"; //下载的文件名 Response.AppendHeader("content-disposition", "attachment;filename=" + name); //文件的大小 Response.AppendHeader("Content-Length", file.Length.ToString()); Response.WriteFile(path); }