Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 18th, 2005, 03:33 AM
Alphonse Giambrone
Guest
 
Posts: n/a
Default Multiple Search Pattern for Directory.GetFiles

Is there a way to use multiple search patterns when calling
Directory.GetFiles.
For instance Directory.GetFiles("C:\MyFolder", "*.aspx") will return all
files with the aspx extension.
But what if I wanted all files with either an aspx OR htm extension?
Any way to get that without calling the method twice?
--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us



  #2  
Old November 18th, 2005, 03:37 AM
Steven Cheng[MSFT]
Guest
 
Posts: n/a
Default RE: Multiple Search Pattern for Directory.GetFiles

Hi Alphonse,


Thanks for posting in the community! My name is Steven, and I'll be
assisting you on this issue.
From your description, you're looking for some information how to specify a
string pattern for the Diretory.GetFile method so as to implement searching
for multi extensions of files, yes ?
If there is anything I misunderstood, please feel free to let me know.


As for this problem, I've viewed the "Directory" class 's document in MSDN,
the "GetFile" method's "pattern" argument seems seems not to support the
multi extensions search pattern. The only permitted search pattern Wildcard
character are
"*" and "?". Here is the related description in MSDN:
---------------------------------------------------------
searchPattern
The search string to match against the names of files in path. The
parameter cannot end in two periods ("..") or contain two periods ("..")
followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it
contain any of the characters in InvalidPathChars.

---------------------------------------------------------
For more detailed description on the method, you may view the following
reference in MSDN:
http://msdn.microsoft.com/library/en...IODirectoryCla
ssGetFilesTopic2.asp?frame=true

Also, the pattern string doesn't support regular expression. And I also
tested using other separator charactors such as "," or ";" or white space
as the separator for multi-extensions , for example "*.aspx, *.htm", but
still not work. I think this maybe an acutal limit for the
Directory.GetFile method, do you think so? BTW, do you think it possible
calling the method multi-times to workaround this? Or if you have any
difficulties with this problem, would you please let me know some further
info about the problem, I'll be willing to help you.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


  #3  
Old November 18th, 2005, 03:37 AM
Alphonse Giambrone
Guest
 
Posts: n/a
Default Re: Multiple Search Pattern for Directory.GetFiles

Thanks Steven, I had a feeling that would be the case and have worked out a
routine to call it multiple times.

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us


"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:nAeuXxV4DHA.2488@cpmsftngxa07.phx.gbl...[color=blue]
> Hi Alphonse,
>
>
> Thanks for posting in the community! My name is Steven, and I'll be
> assisting you on this issue.
> From your description, you're looking for some information how to specify[/color]
a[color=blue]
> string pattern for the Diretory.GetFile method so as to implement[/color]
searching[color=blue]
> for multi extensions of files, yes ?
> If there is anything I misunderstood, please feel free to let me know.
>
>
> As for this problem, I've viewed the "Directory" class 's document in[/color]
MSDN,[color=blue]
> the "GetFile" method's "pattern" argument seems seems not to support the
> multi extensions search pattern. The only permitted search pattern[/color]
Wildcard[color=blue]
> character are
> "*" and "?". Here is the related description in MSDN:
> ---------------------------------------------------------
> searchPattern
> The search string to match against the names of files in path. The
> parameter cannot end in two periods ("..") or contain two periods ("..")
> followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can[/color]
it[color=blue]
> contain any of the characters in InvalidPathChars.
>
> ---------------------------------------------------------
> For more detailed description on the method, you may view the following
> reference in MSDN:
>[/color]
http://msdn.microsoft.com/library/en...IODirectoryCla[color=blue]
> ssGetFilesTopic2.asp?frame=true
>
> Also, the pattern string doesn't support regular expression. And I also
> tested using other separator charactors such as "," or ";" or white space
> as the separator for multi-extensions , for example "*.aspx, *.htm", but
> still not work. I think this maybe an acutal limit for the
> Directory.GetFile method, do you think so? BTW, do you think it possible
> calling the method multi-times to workaround this? Or if you have any
> difficulties with this problem, would you please let me know some further
> info about the problem, I'll be willing to help you.
>
>
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.