gpt4 book ai didi

c# - 是否可以将 FolderBrowserDialog.RootFolder 设置为字符串中的任意路径?

转载 作者:太空狗 更新时间:2023-10-29 22:20:12 27 4
gpt4 key购买 nike

我正在尝试这样做

FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.RootFolder = "C:\SomeUserSelectedFolder";

但是 RootFolder 是一个 System.Environment.SpecialFolder

这是否意味着我只能将它设置到像我的文档或桌面这样的地方?!?

最佳答案

这是正确的:如果 RootFolder 的分配值不是 Environment.SpecialFolder 值之一,则 an InvalidEnumArgumentException is raised .

你可以设置SelectedPath , 虽然:

If the SelectedPath property is set before showing the dialog box, the folder with this path will be the selected folder, as long as SelectedPath is set to an absolute path that is a subfolder of RootFolder (or more accurately, points to a subfolder of the shell namespace represented by RootFolder).

关于c# - 是否可以将 FolderBrowserDialog.RootFolder 设置为字符串中的任意路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7809370/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com