In Windows Forms, you can use the FolderBrowserDialog class to display a dialog box that allows the user to select a folder.
Then, you can set the initial directory of the FolderBrowserDialog to the folder where the program starts by setting the SelectedPath property of the dialog box to the application's startup path.
using System.Windows.Forms;
// ...
// Show the Folder Browser dialog
FolderBrowserDialog folderDialog = new FolderBrowserDialog();
// Set the initial directory to the application's startup path.
dialog.SelectedPath = Application.StartupPath;
if (folderDialog.ShowDialog() == DialogResult.OK)
{
// 선택한 폴더 경로 가져오기
string selectedPath = folderDialog.SelectedPath;
// 선택한 경로를 사용하여 파일 다운로드
// ...
}
- This code creates a new instance of the FolderBrowserDialog class, sets its SelectedPath property to the application's startup path, shows the dialog, and gets the result. If the user clicked the OK button, the code gets the selected folder path and uses it for downloading files.
This article was adapted using ChatGPT and DeepL.
Top comments (0)