问题描述
我目前正在编写一个轻巧灵活的程序来查看和编辑图片.一切进展顺利,但我遇到了障碍. FolderBrowserDialog控件的RootFolder属性是Environment.SpecialFolder类型的,它是一个枚举.由于这种性质,我无法将其值设置为字符串.如何使用FolderBrowserDialog的SelectedPath属性设置FolderBrowserDialog的RootPath属性?
(注意:FolderBrowserDialog用于选择从中打开图像的默认文件夹)
I currently am writing a lightweight and flexible program to view and possibly edit pictures. Everything is going smoothly, but I''ve run into a roadblock. The RootFolder property of a FolderBrowserDialog control is of the Environment.SpecialFolder type, which is an enum. Due to this nature, I can''t set its value as a string. How can I use the SelectedPath property of the FolderBrowserDialog to set the RootPath property for a FolderBrowserDialog?
(Note: The FolderBrowserDialog is for selecting the default folder for opening images from)
推荐答案
FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.RootFolder = Environment.SpecialFolder.MyComputer;
dlg.SelectedPath = @"d:\dev";
dlg.ShowDialog();
这篇关于如何在Environment.SpecialFolder中使用FolderBrowserDialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!