允许用户在 C# WinForms 应用程序中选择文件/文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/992355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:05:20  来源:igfitidea点击:

Allow user to choose file/folder in C# WinForms app

c#winforms

提问by UnkwnTech

How can I user to choose a file or a folder from within my forms app?
Is there not a built in component for it?

用户如何从我的表单应用程序中选择文件或文件夹?
没有内置组件吗?

采纳答案by Jon Skeet

There are a few depending on exactly what you need to do:

有几个取决于您需要做什么:

回答by AKo

You can use CommonOpenFileDialogby WindowsAPICodePackpackage to select a file and dialog.IsFolderPicker = trueto enable folder selection

您可以CommonOpenFileDialogWindowsAPICodePack包使用来选择文件并dialog.IsFolderPicker = true启用文件夹选择