How can I do this?
I want a user to click a button and then a small window pops up and lets me end-user navigate to X folder. Then I need to save the location of the folder to a string variable.
Any help, wise sages of StackOverflow?
How can I do this?
I want a user to click a button and then a small window pops up and lets me end-user navigate to X folder. Then I need to save the location of the folder to a string variable.
Any help, wise sages of StackOverflow?
If you're using Winforms, you can use a FolderBrowserDialog control. The path the user selects will be in the SelectedPath property.
using (FolderBrowserDialog dlg = new FolderBrowserDialog())
{
if (dlg.ShowDialog(this) == DialogResult.OK)
{
string s = dlg.SelectedPath;
}
}
(remove this
if you aren't already in a winform)
string path = null;
FolderBrowserDialog dlg = new ();
if (dlg.ShowDialog() == DialogResult.OK)
{
path = dlg.SelectedPath;
}