Mar 21, 2014

How to implement open filedialogbox in c#

C# Code:

String ImagePath=””;
OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
OpenFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
OpenFileDialog1.Filter = "(*.png)|*.png|All Files (*.*)|*.*";
OpenFileDialog1.FilterIndex = 1;

if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
{
    ImagePath= OpenFileDialog1.FileName;

}