public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { FolderBrowser2 browser = new FolderBrowser2(); if (value != null) { browser.DirectoryPath = string.Format("{0}", value); } if (browser.ShowDialog(null) == DialogResult.OK) return browser.DirectoryPath; return value; }
/// <summary> /// 选择文件 /// </summary> /// <returns></returns> public string ChoseFolders(String path) { lblStatus.Text = "正在读取图片"; FolderBrowser2 folderSelect = new FolderBrowser2(); DialogResult result = folderSelect.ShowDialog(null); if (result == DialogResult.OK || result == DialogResult.Yes) { return folderSelect.DirectoryPath; } else { lblStatus.Text = ""; } return ""; }