C# 文件操作

时间:2014-04-30 23:34:03   收藏:0   阅读:443

【创建目录】

using System.IO;

Directory.CreateDirectory(FilePath);

【使用WriteFile下载文件】

bubuko.com,布布扣
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(); }
bubuko.com,布布扣

 

C# 文件操作,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!