PC Review


Reply
Thread Tools Rate Thread

Directory Scan using Wildcards?

 
 
DavidM
Guest
Posts: n/a
 
      17th Jun 2008
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.

 
Reply With Quote
 
 
 
 
zacks@construction-imaging.com
Guest
Posts: n/a
 
      17th Jun 2008
On Jun 17, 1:48*pm, DavidM <Dav...@discussions.microsoft.com> wrote:
> 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
 
Reply With Quote
 
Ignacio Machin ( .NET/ C# MVP )
Guest
Posts: n/a
 
      17th Jun 2008
On Jun 17, 1:48*pm, DavidM <Dav...@discussions.microsoft.com> wrote:
> 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") ))

 
Reply With Quote
 
DavidM
Guest
Posts: n/a
 
      17th Jun 2008
Thank you all!



"Ignacio Machin ( .NET/ C# MVP )" wrote:

> On Jun 17, 1:48 pm, DavidM <Dav...@discussions.microsoft.com> wrote:
> > 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") ))
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to scan directory , list all the file moonhk Microsoft Excel Programming 3 23rd Oct 2006 03:59 PM
Query/Scan Active Directory =?Utf-8?B?S2l0Q2F6?= Microsoft Access VBA Modules 0 19th Jul 2006 03:24 AM
Scan a Directory jjresti Microsoft Excel Programming 5 9th Sep 2005 12:08 PM
Active Directory Search wildcards Netmonster Microsoft C# .NET 2 25th Mar 2005 03:30 PM
method to Scan tables in one directory souris Microsoft Access 5 12th Mar 2005 07:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 AM.