473,394 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Deleting files using wildcards

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.*"

Jul 17 '06 #1
4 7462
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)

"BobRoyAce" <br**@omegasoftwareinc.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.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.*"

Jul 17 '06 #2
Shell """%comspec%"" /c del ""File123.*"""

Mike.

"BobRoyAce" <br**@omegasoftwareinc.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.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.*"


Jul 17 '06 #3
Or try Kill("File123*.*")
Michael D. Ober wrote:
Shell """%comspec%"" /c del ""File123.*"""

Mike.

"BobRoyAce" <br**@omegasoftwareinc.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.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.*"
Jul 17 '06 #4
John Timney (MVP) wrote:
"BobRoyAce" <br**@omegasoftwareinc.comwrote in message
news:11**********************@35g2000cwc.googlegro ups.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.
DirectoryInfo.GetFiles will do the first part of this for you (I only
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

Jul 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Alec S. | last post by:
Hi, I'm using JavaScript and Cookies for some customization in a web page. There may be several values in the cookie with names that are not known at runtime. I need a way of deleting them. ...
0
by: plucier | last post by:
Hey everybody. I'm not a programmer myself, but I'm working with a group of programmers and we've run into a problem. We have a situation where we need to delete files on a network drive. All...
0
by: Hrvoje Vrbanc | last post by:
Hello, this is a problem I came upon while building a site based on MCMS 2002 but it's not strictly MCMS-oriented: I have a page that displays a certain content in presentation mode but when an...
2
by: Dennis | last post by:
I am trying to implement a "Find and Replace" dialog that allows using wildcards in the find string, much like the Find and Replace Dialogs in Ms Word, etc. Are there any references or examples on...
0
by: Web learner | last post by:
Individual file download works fine. But when I try to download multiple files, for example using wildcards in the following code, I get error. How to solve it? System.Net.WebClient Client = new...
2
by: Josh Kandiko | last post by:
Hi, I've been having some frustrations with deleting files from the Isolated Storage directories. Basically, I want my application to remove all instances of configuration information for my...
3
by: hajmula2004 | last post by:
i have a problem in deleting the files using c and please somebody help me
3
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hi, does anyone know if I can scan a subdirectory using wildcards? I do not see a way to do this using: string folder = @"C:\INPUT\CUSTOMERS\ID???BC.*" DirectoryInfo di = new...
0
by: brat33 | last post by:
I have lots of files that need monthly cleanup done on them. These files are located in many different directories on the same server. Some example files names are C1234.idx, C1111.idx, C8693.idx,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.