ASP NET MVC 5 Delete File From Server
use Request.MapPath
string fullPath = Request.MapPath("~/Images/Cakes/" + photoName);
if (System.IO.File.Exists(fullPath))
{
System.IO.File.Delete(fullPath);
}
File
, as you're using it, is ambiguous, hence the "squiggly line". The IDE can't resolve which you mean;
System.Web.Mvc.Controller.File()
or
System.IO.File
Use a fully-qualified name when trying to use the File API within an MVC controller.