FolderDialog in ConsoleApplication C #

3

I have a question regarding Console Application, how do I open a window similar to this one where it is possible to select a FOLDER?

ItwouldbeafeatureequaltowhatexistsinWindowsFormswhere FolderBrowserDialog .

I use the .NET Framework 4.5.

    
asked by anonymous 18.06.2015 / 21:24

1 answer

2

Do this,

Just instantiate and call.

static class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        FolderBrowserDialog fbd = new FolderBrowserDialog();
        if (fbd.ShowDialog() == DialogResult.OK)
        {
            foreach (var path in Directory.GetFiles(fbd.SelectedPath))
            {
                Console.WriteLine(path); // full path
                Console.WriteLine(System.IO.Path.GetFileName(path)); // file name
            }
        }


    }
}

Source: link

YOU MUST ADD TO REF. for System.Windows.Forms

As our friend @Iago Correia Guimarães remembered well.

    
18.06.2015 / 21:36