I am writing a small utility that starts with selecting a file, and then I need to select a folder. I would like to indicate by default the folder in which the selected file was selected.
OpenFileDialog.FileName returns the full path and file name - I want to get only part of the path (sans filename), so I can use this as the initial selected folder
private System.Windows.Forms.OpenFileDialog ofd; private System.Windows.Forms.FolderBrowserDialog fbd; ... if (ofd.ShowDialog() == DialogResult.OK) { string sourceFile = ofd.FileName; string sourceFolder = ???; } ... fbd.SelectedPath = sourceFolder;
Are there any .NET methods for this, or do I need to use regex, split, trim, etc.
Kevin Haines Jan 13 '09 at 13:51 2009-01-13 13:51
source share