简体   繁体   English

让用户在 C# 中选择子目录的最佳方法是什么?

[英]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.

相关问题 允许用户在C#中浏览文件的最佳方法是什么? - What's the best way to allow a user to browse for a file in C#? 在c#中确定程序员是通过IDE还是用户运行程序的最佳方法是什么? - What is the best way in c# to determine whether the programmer is running the program via IDE or it's user? 从C#中的Brushes集合中选择随机画笔的最佳方法是什么? - What is the best way to pick a random brush from the Brushes collection in C#? 在 C# 和 sql 中管理应用程序用户选项的最佳方法是什么? - what is the best way to manage application user options in C# and sql? 在C#中存储用户特定数据的最佳方法是什么? - What is the best way to to store user specific data in C#? 在C#中引发异常的最佳方法是什么? - What's the best way to raise an exception in C#? 删除部分字符串的最佳方法是什么? (C#) - What's the best way to remove portions of a string? (C#) 在C#中为外部开发人员提供库的最佳方法是什么? - What's the best way to provide a library to external developers in C#? 在C#中设计全屏应用程序的最佳方法是什么? - What's the best way to design a full screen application in C#? C# - 使用 TcpListener(异步)的最佳方式是什么 - C# - What's the best way to use TcpListener (async)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM