Directory Scan using Wildcards?

D

DavidM

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

zacks

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/library/aa328760(VS.71).aspx
 
I

Ignacio Machin ( .NET/ C# MVP )

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") ))
 
D

DavidM

Thank you all!



Ignacio Machin ( .NET/ C# MVP ) said:
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") ))
 

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

Top