<p>On a file path field, I want to capture the directory path like:</p>

<pre><code>textbox1.Text = directory path
</code></pre>

<p>Anyone?</p>

[{'answer_id': 80824, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 3, 'selected': False, 'text': '<p>There is a FolderBrowserDialog class that you can use if you want the user to select a folder.</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.folderbrowserdialog.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.folderbrowserdialog.aspx</a></p>\n\n<pre><code>DialogResult result = folderBrowserDialog1.ShowDialog();\nif (result.Equals(get_DialogResult().OK)) {\n    textbox1.Text = folderBrowserDialog1.get_SelectedPath();\n}\n</code></pre>\n\n<p>If all you want is to get the direcotory from a full path, you can do this:</p>\n\n<pre><code>textbox1.Text = Path.GetDirectoryName(@"c:\\windows\\temp\\myfile.txt");\n</code></pre>\n\n<p>This will set the Text-property to "c:\\windows\\temp\\"</p>\n'}, {'answer_id': 81047, 'author': 'MarlonRibunal', 'author_id': 10385, 'author_profile': 'https://Stackoverflow.com/users/10385', 'pm_score': 3, 'selected': True, 'text': '<p>Well I am using VS 2008 SP1. This all I need:</p>\n\n<pre><code>private void button1_Click(object sender, EventArgs e)\n{\n    FolderBrowserDialog profilePath = new FolderBrowserDialog();\n\n    if (profilePath.ShowDialog() == DialogResult.OK)        \n    {\n        profilePathTextBox.Text = profilePath.SelectedPath;\n    }\n    else\n    {\n        profilePathTextBox.Text = "Please Specify The Profile Path";\n    }\n}\n</code></pre>\n'}, {'answer_id': 6281800, 'author': 'Pat', 'author_id': 116891, 'author_profile': 'https://Stackoverflow.com/users/116891', 'pm_score': 1, 'selected': False, 'text': '<p>If you don\'t want a terrible, non-user friendly dialog*, try <a href="http://www.ookii.org/software/dialogs/" rel="nofollow noreferrer">Ookii.Dialogs</a> or see other answers to <a href="https://stackoverflow.com/questions/31059/how-do-you-configure-an-openfiledialog-to-select-folders">How do you configure an OpenFileDialog to select folders?</a>. The only downside I see to Ookii is that it requires .NET 4 Full, not just Client Profile. But the source is included in the download, so I\'m going to work on that. Too bad the license isn\'t LGPL or similar...</p>\n\n<p>See also: <a href="https://stackoverflow.com/questions/4342895/winforms-message-box-with-textual-buttons">WinForms message box with textual buttons</a></p>\n\n<p>*This is what FolderBrowserDialog looks like:</p>\n\n<p><img src="https://i.stack.imgur.com/NvD6F.png" alt="Ugly, unfriendly folder browser dialog"></p>\n'}]
['https://Stackoverflow.com/questions/80820', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10385/']