Hi,
You can use FileOpenDialog and FolderBrowserDialog as per your requirement from the application.
http://www.kanbal.com/index.php?/CSharp/file-open-dialog-box-in-csharp.html
Bhaskar
2009-09-14 08:54:31
Hi,
You can use FileOpenDialog and FolderBrowserDialog as per your requirement from the application.
http://www.kanbal.com/index.php?/CSharp/file-open-dialog-box-in-csharp.html
from msdn
private void button1_Click(object sender, System.EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
using (myStream)
{
// Insert code to read the stream here.
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
}