Can not delete file using ASP .NET 2.0 from the images directory within the website

A

Anjan Bhowmik

Hi,

I use a form to upload an image to a directory on my site
(~/Images/UserName/file1.jpg). Using Server.mapPath function i get the
Physical path and save the file using
FileUpload1.PostedFile.SaveAs(filePath) function. The file is saved fine.

I also keep an daabase entry to store the virtual path
(~/Images/UserName/file1.jpg) for that specific user entry. The problem is
when i try to use File.Delete(Server.MapPath("~/Images/UserName/file1.jpg"))
to delete the file i get this error
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top