What is the best way to let the user select a subdirectory in C #?

What is the best way to let the user select a subdirectory in C #?

For example, an application that allows the user to organize all saved html receipts. Most likely, he will want to be able to select the root subdirectory in which the program should search for saved web pages (receipts).

Duplicate:

+3
source share
5 answers

The folder browser dialog is the way to go.

If you want to set the initial path to the folder, you can add this to the form load event:

// Sets "My Documents" as the initial folder path
string myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
FolderBrowserDialog1.SelectedPath = myDocsPath;
+11
source

Check out the FolderBrowserDialog class .

// ...    
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) 
{
    textBox1.Text = folderBrowserDialog1.SelectedPath;
}
+7
source
+2
source

FolderBrowserDialog works, but offers a very small tweak.

If you want a text box where users can enter a path, see here

Dupe of: C # Directory Overview

+2
source

Whatever you do, do not use FolderBrowserDialog.

I'm just joking. Use this.

0
source

Source: https://habr.com/ru/post/1705056/


All Articles