Try Folder Path with FolderBrowserDialog - CSharp System.Windows.Forms

CSharp examples for System.Windows.Forms:Dialog

Description

Try Folder Path with FolderBrowserDialog

Demo Code


using System.Windows.Forms;
using System.Windows;
using System.Linq;
using System.Collections.Generic;

public class Main{
        public static bool TryFolderPath(string description, out string folderPath)
        {/*from   w w w . java  2s.  co m*/
            var folderSelector = new FolderBrowserDialog()
            {
                Description = description
            };
            if (folderSelector.ShowDialog() == DialogResult.OK)
            {
                folderPath = folderSelector.SelectedPath;
                return true;
            }
            else
            {
                folderPath = string.Empty;
                return false;
            }
        }
}

Related Tutorials