Get folder name ONLY from open file dialog /browse
Hi, I want to get folder / directory path in which I browse to (perhaps using OpenFileDialog()) i.e. for example I want to save the default folder name in which End Users can save their Reports. Thanks - Chagbert.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


EhteshamRank #3,979 · 374 reputationPosted May 22, 2012, 4:42 AM EDT
{
if (Dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string Path = Dialog.FileName;
string FolderName = System.IO.Path.GetDirectoryName(Path);
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(FolderName);
MessageBox.Show(info.Name);
}
}
Why not FolderBrowserDialog Control?