Provides a file folder chooser dialog - CSharp File IO

CSharp examples for File IO:Directory

Description

Provides a file folder chooser dialog

Demo Code


using System.Windows.Forms;
using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using System;//from w w w . ja  va  2  s. co m

public class Main{
        /// <summary>
        /// Provides a file folder chooser
        /// </summary>
        /// <returns>the path to the folder chosen or null for no folder selected</returns>
        public static string ChooseFolder()
        {
            var dialog = new FolderBrowserDialog();
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                return dialog.SelectedPath;
            }
            return null;
        }
}

Related Tutorials