Showing posts with label how to get file path. Show all posts
Showing posts with label how to get file path. Show all posts

Wednesday, 17 October 2012

How to get file path in C#

How could i get the right path for a file in C#?

Use openfiledialog,for following code
 
private void button1_Click(object sender,Eventargs e)
{
if(openFileDialog1.ShowDialog()==DialogResult.OK)
{
textbox1.Text=Path.GetFullPath(openFileDialog1.FileName);
}
}
 
addionally add the namespace System.IO;