Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To use FolderBrowserDialog on the company's network to choose a subfolder, follow these steps:

  1. Create a new instance of FolderBrowserDialog class.

  2. Set the RootFolder property of the FolderBrowserDialog instance to the network path of the parent folder where the subfolder is located. For example, if the parent folder is located at "\server\share\parent\", set the RootFolder property to "NetworkPlaces".

  3. Set the ShowNewFolderButton property of the FolderBrowserDialog instance to true if you want to allow the user to create a new subfolder.

  4. Call the ShowDialog method of the FolderBrowserDialog instance to display the dialog box where the user can select the subfolder.

  5. Check the DialogResult property of the FolderBrowserDialog instance to determine if the user clicked the OK button or the Cancel button.

  6. If the user clicked the OK button, get the selected subfolder by accessing the SelectedPath property of the FolderBrowserDialog instance.

  7. Use the selected subfolder in your code as needed.

Here is an example code snippet:

FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.RootFolder = Environment.SpecialFolder.NetworkPlaces;
fbd.SelectedPath = "\\server\share\parent\";
fbd.ShowNewFolderButton = true;
DialogResult result = fbd.ShowDialog();
if (result == DialogResult.OK)
{
    string subfolder = Path.Combine(fbd.SelectedPath, "subfolder");
    // use the selected subfolder here
}