Ask Your Question
4

How can I use FolderBrowserDialog on the company's network to choose a subfolder?

asked 2021-11-02 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-01 22:00:00 +0000

plato gravatar image

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
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-11-02 11:00:00 +0000

Seen: 19 times

Last updated: Jan 01 '23