[英]What's the best way to let a user pick a subdirectory in C#?
What's the best way to let a user pick a subdirectory in C#?让用户在 C# 中选择子目录的最佳方法是什么?
For example, an app that lets the user organize all his saved html receipts.例如,一个允许用户整理他保存的所有 html 收据的应用程序。 He most likely is going to want to be able to select a root subdirectory that the program should search for saved webpages (receipts).
他很可能希望能够 select 程序应该搜索保存的网页(收据)的根子目录。
Duplicate:复制:
The Folder Browser Dialog is the way to go. 文件夹浏览器对话框是 go 的方式。
If you want to set an initial folder path, you can add this to your form load event:如果要设置初始文件夹路径,可以将其添加到表单加载事件中:
// Sets "My Documents" as the initial folder path
string myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
FolderBrowserDialog1.SelectedPath = myDocsPath;
Check the FolderBrowserDialog class.检查文件夹浏览器对话框class 。
// ...
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = folderBrowserDialog1.SelectedPath;
}
FolderBrowserDialog works just fine for this purpose. FolderBrowserDialog为此目的工作得很好。
FolderBrowserDialog works, but offers very little customization. FolderBrowserDialog 有效,但提供的自定义很少。
If you want a textbox where users can type in the path have a look here如果您想要一个用户可以在其中输入路径的文本框, 请查看此处
Dupe of: Browse for a directory in C#重复:浏览 C# 中的目录
Whatever you do, don't use the FolderBrowserDialog
.无论您做什么,都不要使用
FolderBrowserDialog
。
Just kidding.只是在开玩笑。 Use that.
用那个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.