Get Folder To Open using FolderBrowserDialog - CSharp File IO

CSharp examples for File IO:Directory

Description

Get Folder To Open using FolderBrowserDialog

Demo Code


using System.IO ;
using System.Windows.Forms ;
using System;/*from  ww w.  j  a  v  a2 s . co m*/

public class Main{

      public static string GetFolderToOpen(bool newFolderButton)
      {
         FolderBrowserDialog folderDialog = new FolderBrowserDialog() ;
         folderDialog.ShowNewFolderButton = newFolderButton ;
         DialogResult res = folderDialog.ShowDialog() ;
         if(res == DialogResult.OK)
         {
            return folderDialog.SelectedPath ;
         }
         
         return null ;
      }
}

Related Tutorials