首页 > Windows开发 > 详细

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

时间:2015-03-20 16:15:03      阅读:736      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!