Asp.net mvc 4 system.io.file.exists不在mvc4中工作

Asp.net mvc 4 system.io.file.exists不在mvc4中工作,asp.net-mvc-4,kendo-upload,Asp.net Mvc 4,Kendo Upload,我正在从剑道上传控制中删除图像 这是我的密码 public ActionResult Remove(string[] fileNames) { if (fileNames != null) { foreach (var fullName in fileNames) { var fileName = Path.GetFileName(fullName);

我正在从剑道上传控制中删除图像

这是我的密码

  public ActionResult Remove(string[] fileNames)
    {

        if (fileNames != null)
        {
            foreach (var fullName in fileNames)
            {
                var fileName = Path.GetFileName(fullName);
                var physicalPath = Server.MapPath(Path.Combine(("~/AssetAttachments"),fileName));

                if (System.IO.File.Exists(physicalPath))
                {
                     System.IO.File.Delete(physicalPath);
                }
            }
        }
        return Content("");
    }
我拥有的物理路径是E:\karthik-related\JPL\Dev\Src\AssetTrackingSystem\AssetTrackingSystem\assettachments\Attach3.jpg

即使文件和目录可用

  if (System.IO.File.Exists(physicalPath))
正在返回false并脱离状态

感谢您的帮助。

试试这个

FileInfo fi = new FileInfo(Path.Combine(("~/AssetAttachments"),fileName));
 if (fi.Exists)
 {
   fi.Delete();
 }
试试这个:

foreach (var fullName in fileNames)
{
     var physicalPath = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("~/AssetAttachments"), fullName);

     if (System.IO.File.Exists(physicalPath))
     {
         System.IO.File.Delete(physicalPath);
     }
}

即使f1.Exists返回False,也不会出现这种情况jaimin@Karthik您有多个文件要删除吗?
physicalPath
的值是多少?