Windows Develop Bookmark and Share   
 index > Windows Forms General > GetFiles() with two search format
 

GetFiles() with two search format

Hi im trying to get all files with .jpg or .tif format.

or all files except .DAT files.

foreach (String file in Directory.GetFiles(path, "*.TIF; *.jpg"))

{

}

any good suggestions?

thanks!

André Dani  Saturday, February 02, 2008 5:43 PM

I found a good awnser:

DirectoryInfo dir = new DirectoryInfo("c:/images/");
FileInfo[] imageFiles = dir.GetFiles("*.*");
foreach (FileInfo file in imageFiles)
{
if (file.Extension.Equals(".bmp") || file.Extension.Equals(".jpg"))
{
listBox1.Items.Add(Convert.ToString(file.Name));
}
}

hope it helps to enyone!

bye!!

André Dani  Saturday, February 02, 2008 6:01 PM

I found a good awnser:

DirectoryInfo dir = new DirectoryInfo("c:/images/");
FileInfo[] imageFiles = dir.GetFiles("*.*");
foreach (FileInfo file in imageFiles)
{
if (file.Extension.Equals(".bmp") || file.Extension.Equals(".jpg"))
{
listBox1.Items.Add(Convert.ToString(file.Name));
}
}

hope it helps to enyone!

bye!!

André Dani  Saturday, February 02, 2008 6:01 PM

You can use google to search for other answers

Custom Search

More Threads

• Drag and Drop between my application and windows explorer
• Picking up data to auto fill
• How can I access Textboxes and Combo boxes?
• Find textbox
• How can I use double buffering?
• Visual inheritance problems
• Can you store files in memory while manipulating them?
• [WMP] Current playing song as title bar
• Unzipping files in vb.net
• Animated GIF in a picture box causes "A generic error occurred in GDI+." exception