码迷,mamicode.com
首页 > Windows程序 > 详细

C# 判断服务器上文件是否存在

时间:2015-03-20 16:15:33      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:

var path = " FramePath" ;
var filePath = Server.MapPath(path);
if (System.IO.File.Exists(filePath))
{
var fileName = Path.GetFileName(filePath);
FileInfo info = new FileInfo(filePath);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FrameName + ".zip", System.Text.Encoding.UTF8).Replace("+", "%20"));
Response.AppendHeader("Content-Length", info.Length.ToString());
Response.WriteFile(filePath);
Response.Flush();
Response.End();
return new EmptyResult();
}

C# 判断服务器上文件是否存在

标签:

原文地址:http://www.cnblogs.com/etong/p/4353656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!