I have 2 images inside a folder called Pics..... Image1.jpg and Image2.jpg.
What code must i place inside my Submit button to just delete Image1.jpg located here "~/Pics/Image1.jpg"
Any help would be great!!!
I have 2 images inside a folder called Pics..... Image1.jpg and Image2.jpg.
What code must i place inside my Submit button to just delete Image1.jpg located here "~/Pics/Image1.jpg"
Any help would be great!!!
You need to use System.IO.File.Delete not System.IO.Delete
string path = "~/Pics/Image1.jpg";
System.IO.File.Delete(Server.MapPath(path))
i would try:
String FilePath;
FilePath = Server.MapPath("~/Pics/Image1.jpg");
File.Delete(FilePath);
The syntax is:
System.IO.File.Delete(Server.MapPath("~/Pics/Image1.jpg"));
You will need to make sure the user your web app is running as has delete (change) permissions on the file you are deleting, however.