标签:com http style blog class div img code java c log
【创建目录】
using System.IO;
Directory.CreateDirectory(FilePath);
【使用WriteFile下载文件】
using System.Net
private string fileName = HttpContext.Current.Server.UrlEncode("规范.rar"); private string filePath = HttpContext.Current.Server.MapPath("规范.rar"); //使用WriteFile下载文件 protected void btnDL2_Click(object sender, EventArgs e) { FileInfo info = new FileInfo(filePath); long fileSize = info.Length; Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachement;filename=" + fileName); //指定文件大小 Response.AddHeader("Content-Length", fileSize.ToString()); Response.WriteFile(filePath, 0, fileSize); Response.Flush(); Response.Close(); }
标签:com http style blog class div img code java c log
原文地址:http://www.cnblogs.com/ymtianyu/p/3701315.html