I’m trying to delete all files in a folder which start with a specific user id so if the user id = 00000 then I want to delete file 00000-1.xml & 00000-2.xml & 00000-3.xml and so on.
I have this code so far:
Dim path as String = Server.MapPath("../myfolder/xml/00000" & something?? & ".xml")
If path <> "" Then
Dim fileInfo As FileInfo = Nothing
Try
fileInfo = New FileInfo(path)
If fileInfo.Exists Then
File.Delete(path)
End If
Catch
End Try
End If
Obviously I have just added the something?? in as i have no idea what to put there?
Can anyone shed any light on this?
Consider using Directory.GetFiles instead.