There is a FolderBrowserDialog class that you can use if you want the user to select a folder.
http://msdn.microsoft.com/en-us/library/system.windows.forms.folderbrowserdialog.aspx
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result.Equals(get_DialogResult().OK)) {
textbox1.Text = folderBrowserDialog1.get_SelectedPath();
}
If all you need to do is get the directive from the full path, you can do this:
textbox1.Text = Path.GetDirectoryName(@"c:\windows\temp\myfile.txt");
This will set the Text property to "c: \ windows \ temp \"
source
share