Simple file dialog

String[] showFileDialog()
{
    OpenFileDialog dialog = new OpenFileDialog();
 
    dialog.InitialDirectory = ".";
    // Preselect .txt files
    dialog.Filter = "Txt-Dateien|*.txt";
    dialog.FilterIndex = 1;
    dialog.Multiselect = false;
    dialog.RestoreDirectory = true;
 
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        return dialog.FileNames[0];
    }
}

Download this snippet

Shows a simple dialog to pick a file from the local filesystem. In this snippet, only .txt files are preselected.

Twitter Twitter

1 Comments to “ Simple file dialog”

  1. Anonymous  on Jun 11, 2010

    npnqw6 <a href="http://vogekvdnurpl.com/">vogekvdnurpl</a>, [url=http://ibwzcuyybuty.com/]ibwzcuyybuty[/url], [link=http://rmbumwhcsnyj.com/]rmbumwhcsnyj[/link], http://ymwpzvvplvkg.com/

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>