|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Deleting files using wildcardsI 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) Show quoteHide quote "BobRoyAce" <b***@omegasoftwareinc.com> wrote in message news:1153113166.402199.252230@35g2000cwc.googlegroups.com... >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.*" > John Timney (MVP) wrote:
Show quoteHide quote > "BobRoyAce" <b***@omegasoftwareinc.com> wrote in message DirectoryInfo.GetFiles will do the first part of this for you (I only> news:1153113166.402199.252230@35g2000cwc.googlegroups.com... > >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. know this by looking at Reflector's output for Kill, mind...) -- Larry Lard Replies to group please When starting a new topic, please mention which version of VB/C# you are using Shell """%comspec%"" /c del ""File123.*"""
Mike. Show quoteHide quote "BobRoyAce" <b***@omegasoftwareinc.com> wrote in message news:1153113166.402199.252230@35g2000cwc.googlegroups.com... > 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.*" > Or try Kill("File123*.*")
Michael D. Ober wrote: Show quoteHide quote > Shell """%comspec%"" /c del ""File123.*""" > > Mike. > > "BobRoyAce" <b***@omegasoftwareinc.com> wrote in message > news:1153113166.402199.252230@35g2000cwc.googlegroups.com... > > 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.*" > >
Bug or Feature? CancelButton vs Escape Key
overides/loads usage AS400 - Ado.Net from Vb.Net Slow Query Times Problems using Me.Scale in Framework 2.0 ListView and ImageList/ImageKey enforce event calling on inherited classes Holding down a key HELP: Problem Hosting the "Simplest" of VB.NET Apps Is this a bug: 2.2 - 0.4 = 1.8 but 1.2 - 0.4 = 0.8000001 ? detect if running on a terminal server |
|||||||||||||||||||||||