Using:
Directory.GetFiles(string path, string searchPattern)
Is there a way to specify multiple file types in the search pattern What I'm trying to do is get all BMP, PNG, and JPG files from a directory without having to search the same directory three times to get all of the files.
Thanks in advance,
Bill

Directory searching
dotnetgruven
This is what I ended up doing:
string[] files = Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly);
foreach (string s in files)
{
string extension = s.Substring(s.LastIndexOf("."));
if (".jpg .bmp .png .gif".IndexOf(extension) > -1)
{
//Other code
}
}
This seems to do what I want.
Bill
Tonia
Workaround : Get all the files from the directory and then compare each file extension
jonsofield
It is not possible to specify mltiple search patterns, since the search string 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 Info. about this you can check the link from MSDN
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfSystemIODirectoryClassGetFilesTopic2.asp
WorkAround : You can use some recursion and File events to achieve this.