471,344 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Directory Scan using Wildcards?

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 DirectoryInfo(folder);
FileInfo[] fileNames = di.GetFiles("AllInput_*.xml");

Basically, I have lots of foldres under C:\INPUT\CUSTOMERS and I want to the
..XML files I'm looking for only exists under the ID???BC folders. So I
wanted to dymanically get a list of all the ID???BC folders and then scan
each one for the specified files.

I was trying to do this to avoid having to scan all folders. Plus I need a
dymaic list of all the ??? customers.

Jun 27 '08 #1
3 4460
On Jun 17, 1:48*pm, DavidM <Dav...@discussions.microsoft.comwrote:
Hi, does anyone know if I can scan a subdirectory using wildcards? *I donot
see a way to do this using:

* * * * * * * *string folder = @"C:\INPUT\CUSTOMERS\ID???BC.*"

* * * * * * * * DirectoryInfo di = new DirectoryInfo(folder);
* * * * * * * * FileInfo[] fileNames = di.GetFiles("AllInput_*.xml");

Basically, I have lots of foldres under C:\INPUT\CUSTOMERS and I want to the
.XML files I'm looking for only exists under the ID???BC folders. *So I
wanted to dymanically get a list of all the ID???BC folders and then scan
each one for the specified files. *

I was trying to do this to avoid having to scan all folders. *Plus I need a
dymaic list of all the ??? customers.
RTFM.

http://msdn.microsoft.com/en-us/libr...60(VS.71).aspx
Jun 27 '08 #2
On Jun 17, 1:48*pm, DavidM <Dav...@discussions.microsoft.comwrote:
Hi, does anyone know if I can scan a subdirectory using wildcards? *I donot
see a way to do this using:

* * * * * * * *string folder = @"C:\INPUT\CUSTOMERS\ID???BC.*"

* * * * * * * * DirectoryInfo di = new DirectoryInfo(folder);
* * * * * * * * FileInfo[] fileNames = di.GetFiles("AllInput_*.xml");

Basically, I have lots of foldres under C:\INPUT\CUSTOMERS and I want to the
.XML files I'm looking for only exists under the ID???BC folders. *So I
wanted to dymanically get a list of all the ID???BC folders and then scan
each one for the specified files. *

I was trying to do this to avoid having to scan all folders. *Plus I need a
dymaic list of all the ??? customers.
You can use
foreach(string folder in Directory.GetDirectories (@"C:\INPUT\CUSTOMERS
\ID???BC.*"))
foreach( string file in Directory.GetFiles( folder,
("AllInput_*.xml") ))

Jun 27 '08 #3
Thank you all!

"Ignacio Machin ( .NET/ C# MVP )" wrote:
On Jun 17, 1:48 pm, DavidM <Dav...@discussions.microsoft.comwrote:
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 DirectoryInfo(folder);
FileInfo[] fileNames = di.GetFiles("AllInput_*.xml");

Basically, I have lots of foldres under C:\INPUT\CUSTOMERS and I want to the
.XML files I'm looking for only exists under the ID???BC folders. So I
wanted to dymanically get a list of all the ID???BC folders and then scan
each one for the specified files.

I was trying to do this to avoid having to scan all folders. Plus I need a
dymaic list of all the ??? customers.

You can use
foreach(string folder in Directory.GetDirectories (@"C:\INPUT\CUSTOMERS
\ID???BC.*"))
foreach( string file in Directory.GetFiles( folder,
("AllInput_*.xml") ))

Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by S. Han | last post: by
1 post views Thread by Psapg | last post: by
11 posts views Thread by comp.lang.php | last post: by
2 posts views Thread by ats | last post: by
2 posts views Thread by sunset85 | last post: by

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.