Delete multiple files from director

collie

New member
Delete multiple files from director

Hi, I have a web form. When the user decides to delete a picture from the db I want that picture also to be deleted from the directory. The pictures are all named after the user's id (ad_id). However, the directory can contain 12.gif and 12.jpg. I want that both pictures will be deleted from the directory. As I mentioned the pictures are named according to the user's id and the ad_id is received from a request.querystring ("ad_id"). This is what I was able to come up with but naturally it doesn't delete the pictures from the directory. Function DeleteFile() Dim objFile As System.IO.File Dim filExists As Boolean '** check if file exists Try filExists = objFile.Exists(Server.MapPath("https://timg.co.il/f/" & ad_id & " ")) '** If file exists then delete it If filExists = True Then objFile.Delete(Server.MapPath("https://timg.co.il/f/" & ad_id & " ")) End If Catch Response.Write("No file found") End Try End Function​
 
למעלה