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...)
 

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

Similar Threads


Back
Top