How to

create file open dialog

Published: 14. December 2008 | Updated: 14. December 2008
License: Microsoft Public License (MS-PL)
Categories: Winforms
Tags: C# File System UI Winforms
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at analyzant.com

Snippet example shows how to create file open dialog

Import namespace

using System.Windows.Forms;

Code

OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = "Open file";
dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
dialog.RestoreDirectory = true;

if (dialog.ShowDialog() == DialogResult.OK)
{
    MessageBox.Show(dialog.FileName);
}
Send us feedback about this snippet »



Related Snippets: