Deleting files using wildcards

  • Thread starter Thread starter BobRoyAce
  • Start date Start date
B

BobRoyAce

I know I can use code like follows to delete a file:

My.Computer.FileSystem.DeleteFile(File123.TAB",
FileIO.UIOption.OnlyErrorDialogs,
FileIO.RecycleOption.DeletePermanently)

How can I delete all files matching text including wildcard(s)? For
example, how can I delete all files beginning with "File123" -->
"File123.*"
 
If you recursively search the directory you could quite easily use a regular
expression to identify each file and then use DeleteFile to delete it.

Regards

John Timney (MVP)
 
John said:
If you recursively search the directory you could quite easily use a regular
expression to identify each file and then use DeleteFile to delete it.

DirectoryInfo.GetFiles will do the first part of this for you (I only
know this by looking at Reflector's output for Kill, mind...)
 
Back
Top