/// <summary> /// 根据文件路径判断文件是否存在 /// </summary> /// <param name="filepath">文件路径</param> /// <param name="model">返回模式,m:返回map地址不检查文件是否存在,c:检测文件是否存在,并返回map地址</param> /// <param name="mappath">map路径</param> /// <returns></returns> public static bool FileExistMapPath(string filepath, FileCheckModel model, out string mappath) { bool checkresult = false; switch (model) { case FileCheckModel.M: mappath = HttpContext.Current.Server.MapPath(filepath); checkresult = true; break; case FileCheckModel.C: if (File.Exists(System.Web.HttpContext.Current.Server.MapPath(filepath))) { mappath = HttpContext.Current.Server.MapPath(filepath); checkresult = true; } else { mappath = null; checkresult = false; } break; default: mappath = ""; checkresult = false; break; } return(checkresult); }
/// <summary> /// 根据文件路径判断文件是否存在 /// </summary> /// <param name="filepath">文件路径</param> /// <param name="model">返回模式,m:返回map地址不检查文件是否存在,c:检测文件是否存在,并返回map地址</param> /// <param name="mappath">map路径</param> /// <returns></returns> public static bool FileExistMapPath(string filepath, FileCheckModel model, out string mappath) { bool checkresult = false; switch (model) { case FileCheckModel.M: mappath = HttpContext.Current.Server.MapPath(filepath); checkresult = true; break; case FileCheckModel.C: if (File.Exists(System.Web.HttpContext.Current.Server.MapPath(filepath))) { mappath = HttpContext.Current.Server.MapPath(filepath); checkresult = true; } else { mappath = null; checkresult = false; } break; default: mappath = ""; checkresult = false; break; } return checkresult; }