DirectoryInfo.GetFiles... Whats the search pattern format? 
Author Message
 DirectoryInfo.GetFiles... Whats the search pattern format?

How can i define the search pattern for GetFiles with more than one extension?

I've tried.

DirectoryInfo.GetFiles("*.jpg; *.gif")
DirectoryInfo.GetFiles("*.jpg;*.gif")

DirectoryInfo.GetFiles("*.jpg, *.gif")
DirectoryInfo.GetFiles("*.jpg,*.gif")

DirectoryInfo.GetFiles("*.jpg|*.gif")
DirectoryInfo.GetFiles("*.jpg| *.gif")

DirectoryInfo.GetFiles("(*.jpg)|(*.gif)")
DirectoryInfo.GetFiles("(*.jpg)| (*.gif)")

DirectoryInfo.GetFiles("(*.jpg)(*.gif)")
DirectoryInfo.GetFiles("(*.jpg;) (*.gif)")

DirectoryInfo.GetFiles("*.jpg*.gif")
DirectoryInfo.GetFiles("*.jpg *.gif")

Nothing...

Is this possible???

Thanks!

--
Matt MacLean
__________



Sun, 30 Jan 2005 07:29:47 GMT  
 DirectoryInfo.GetFiles... Whats the search pattern format?
Hi Matt,

There are two ways:
1. Call Directory.GetFiles for each extension.
2. Use regular expression. You can keep from making multiple calls to
GetFiles() by using regular expressions.

//simplified version

//robust version

RegexOptions.IgnoreCase);

foreach (FileInfo fi in di.GetFiles()) {
    if (r.IsMatch(fi.Extension))
       Console.WriteLine(fi.FullName);
 }

The $ is a directive to only match on the end of the input string. The
backslash escapes the dot, otherwise the evaluation engine treats the dot
as a wildcard. This ensures that files such as foo.jpg_bak are excluded.

This posting is provided "AS IS" with no warranties, and confers no rights.

Regards,

Bill Cheng
Microsoft Support Engineer
--------------------


| Subject: DirectoryInfo.GetFiles... Whats the search pattern format?
| Date: Tue, 13 Aug 2002 17:29:47 -0600
| Lines: 107
| Organization: mmmDesign
| MIME-Version: 1.0
| Content-Type: multipart/alternative;
|       boundary="----=_NextPart_000_0097_01C242EF.05BA2F20"
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 142.59.22.117
| Path: cpmsftngxa06!tkmsftngp01!tkmsftngp11
| Xref: cpmsftngxa06 microsoft.public.dotnet.languages.vb:59408
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| How can i define the search pattern for GetFiles with more than one
extension?
| I've tried.
| DirectoryInfo.GetFiles("*.jpg; *.gif")
| DirectoryInfo.GetFiles("*.jpg;*.gif")
| DirectoryInfo.GetFiles("*.jpg, *.gif")
| DirectoryInfo.GetFiles("*.jpg,*.gif")
| DirectoryInfo.GetFiles("*.jpg|*.gif")
| DirectoryInfo.GetFiles("*.jpg| *.gif")
| DirectoryInfo.GetFiles("(*.jpg)|(*.gif)")
| DirectoryInfo.GetFiles("(*.jpg)| (*.gif)")
| DirectoryInfo.GetFiles("(*.jpg)(*.gif)")
| DirectoryInfo.GetFiles("(*.jpg;) (*.gif)")
| DirectoryInfo.GetFiles("*.jpg*.gif")
| DirectoryInfo.GetFiles("*.jpg *.gif")
| Nothing...
| Is this possible???
| Thanks!
| --
| Matt MacLean
| __________
|



Mon, 31 Jan 2005 10:09:53 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. searching items and pattern matching

2. searching a listbox for a dos pattern...

3. Rich Text Box Pattern Search

4. patterns within patterns ?

5. pattern within a pattern ?

6. SQL formatting - whats your method

7. Serialize Directoryinfo class using XMLSerializer

8. Serializing DirectoryInfo Class for WebService

9. DirectoryInfo

10. Puzzled about DirectoryInfo

11. String Search in Hyperlink formatted field A97

12. getfile method

 

 
Powered by phpBB® Forum Software