'How to use 'System.IO.File.Delete' on server ASP.NET?
I find a trouble/error to use System.IO.File.Delete in ASP.NET, when in the local is success, but when I try to publish and running in the server it's not working or files are not deleted.
this is my code :
string path = HttpContext.Current.Server.MapPath("~/Uploads/Photo/");
string fullPath = path + "myPhoto.jpg";
if (System.IO.File.Exists(fullPath))
{
System.IO.File.Delete(fullPath);
}
else
{
return Request.CreateResponse(HttpStatusCode.OK, new
{
status = true,
message = "File is not exist",
redirect = "",
data = ""
});
}
Please anyone help me solve this problem. Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
