コード例 #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            FolderBrowserDialogEx browser = new FolderBrowserDialogEx();

            if (value != null)
            {
                browser.DirectoryPath = string.Format("{0}", value);
            }
            if (browser.ShowDialog(null) == DialogResult.OK)
            {
                return(browser.DirectoryPath);
            }
            return(value);
        }
コード例 #2
0
ファイル: UDir.cs プロジェクト: halfmoon2014/localtest
        /// <summary>
        /// 选择文件夹
        /// </summary>
        /// <param name="desc">说明</param>
        /// <param name="dir">返回true则path为选择文件夹路径</param>
        /// <returns>是否选择文件夹</returns>
        public static bool SelectDirEx(string desc, ref string dir)
        {
            bool bOk = false;

            using (FolderBrowserDialogEx fd = new FolderBrowserDialogEx {
                Description = desc, DirectoryPath = dir
            })
            {
                if (fd.ShowDialog(null) == DialogResult.OK)
                {
                    dir = fd.DirectoryPath.DealPath();
                    bOk = true;
                }
            }

            return(bOk);
        }