.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Retrieve Path of a File Using OpenFileDialog

Posted By:shiv chandra       Posted Date: June 30, 2011    Points: 40    Category: File Operation    URL: http://www.dotnetspark.com  

Retrieve The Path of a File Using OpenFileDialog

OpenFileDialog fd = new OpenFileDialog();

string NameOfFile = "";
string path = "";

if (fd.ShowDialog() == DialogResult.OK)
  NameOfFile = System.IO.Path.GetFileName(fd.FileName);
  path = System.IO.Path.GetDirectoryName(fd.FileName);

MessageBox.Show(NameOfFile, "Name Of File");
MessageBox.Show(path, "Directory");


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend