OpenFileDialog Filter

Z

Zagor

Hi All,

does anyone knows how to set the filter of the OpenFileDialog to a single
file?

I.E: I have a file "myfile.exe" , I want to force the OpenFileDialog to
search and display and see only that file when browsing ...no other exe.

Thank you

Zagor
 
J

Jens Hoffmann

public string activeFile = "myfile.exe";

private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
//this.openFileDialog1.Filter = "exe files (*.exe)|myfile.exe|All files (*.*)|*.*";
//string filter = "exe files (*.exe)|" + activeFile;
string filter = " |" + activeFile;
this.openFileDialog1.Filter = filter;
this.openFileDialog1.FileName = activeFile;
this.openFileDialog1.ShowDialog();
}

//The commented lines are variants. Add file searching code
//when initializing the activeFile variable.

Greets

Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top