Get File From Folder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.

I have to know about file in folder with *.jpg extend.
I use this fragment of code.

DirectoryInfo directory;
ArrayList file = new ArrayList();
directory = new DirectoryInfo(folderPAth);
foreach( FileInfo dir in directory.GetFiles("*.jpg") )
{
file.Add(dir.FullName);
}

What to do, that show file with *.bmp and *.jpg extend.
I try:
foreach( FileInfo dir in directory.GetFiles("*.jpg" | *.bmp) )
{...}
but its wrong way.

thank you
bay
Pawel
 
Hi Simon (or Pawel),

To my knowledge Directory.GetFiles can only use a single search pattern, that is only *.jpg OR *.bmp etc.

Assuming you have an array or a list of patterns you can do

ArrayList list = new ArrayList();
foreach(string pat in patterns)
{
list.AddRange(Directory.GetFiles(path, pat);
}
 
Back
Top