ASP.NET File.Delete with a Wildcard
I wanted to delete all files within a directory that have a certain string in it, but File.Delete doesn’t allow wildcards. So, I wrote up this little tid-bit that cleared up that problem =)
Dim files() As String = Directory.GetFiles(Server.MapPath(“/Directory/”), “*” strMatchingString “.*”)
Dim strFile As String = “”
For Each strFile In files
File.Delete(strFile)
Next
Cheers!
.: Adam
April 15th, 2011 at 9:41 am
bro, very nice piece of code. It is much appreciated.