文件名称:ASP.NET 对文件进行在线压缩并下载
文件大小:9KB
文件格式:CS
更新时间:2014-09-18 03:37:59
ASP.NET 在线压缩 下载
string local_directoy="";//要压缩的文件夹路径多文件路径 string zipname ="";//压缩后的文件名 ------- // ------- ZipHelp.Zip(local_directoy, zipname, ""); responseFile(zipname);//下载压缩包 private void responseFile(string filepath) { FileInfo fi = new FileInfo(filepath); long size = fi.Length;//文件的大小 string filename = HttpUtility.UrlEncode(System.Text.UTF8Encoding.UTF8.GetBytes(Path.GetFileName(filepath))); Response.Clear(); Response.AddHeader("content-type", "application/x-msdownload;"); Response.AddHeader("Content-Disposition", "attachment;filename=" + filename); Response.AddHeader("content-length", size.ToString()); Response.WriteFile(filepath, 0, size); Response.Flush(); Response.Close(); }