// Factory Methods
        public static FolderBrowserDialogEx PrinterBrowser()
        {
            FolderBrowserDialogEx x = new FolderBrowserDialogEx();

            // avoid MBRO comppiler warning when passing _rootFolderLocation as a ref:
            x.BecomePrinterBrowser();
            return(x);
        }
示例#2
0
        public static string OpenFolderBrowserDialog(string path = "")
        {
            string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            FolderBrowserDialogEx openPath = new FolderBrowserDialogEx()
            {
                Description           = "Choose a directory",
                ShowNewFolderButton   = false,
                SelectedPath          = Directory.Exists(path) ? path : desktop,
                ShowEditBox           = true,
                ShowFullPathInEditBox = true
            };
            DialogResult result = openPath.ShowDialog();

            if ((Directory.Exists(openPath.SelectedPath) || openPath.SelectedPath == desktop) && result == DialogResult.OK)
            {
                return(openPath.SelectedPath);
            }
            return(string.Empty);
        }
        /// <summary>
        /// Öffnet einen FolderBrowserDialog und lässt den Benutzer einen Pfad auswählen
        /// </summary>
        /// <returns></returns>
        private string OpenFileBrowser(string path = "")
        {
            FolderBrowserDialogEx openPath = new FolderBrowserDialogEx()
            {
                Description           = "Choose a directory",
                ShowNewFolderButton   = false,
                SelectedPath          = Directory.Exists(path) ? path : Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                ShowEditBox           = true,
                ShowFullPathInEditBox = true
            };

            openPath.ShowDialog();
            if (Directory.Exists(openPath.SelectedPath))
            {
                return(openPath.SelectedPath);
            }
            else
            {
                return(string.Empty);
            }
        }