C# and select a directory

Posted on 2005-05-06
Last Modified: 2007-12-19

I know about the OpenFileDialog class in C# that lets a user browse to a file and open it, but I was wondering if it is possible to allow a user to browse to a directory, and select that.

I guess the best example I can think of for this would be a driver installation, whereby the program asks you to select a directory that the program can search for the driver information.  The user doesn't select a file, but rather a directory.

Is this possible through the OpenFileDialog class, or some other way?
Question by:Sebastion
    LVL 19

    Accepted Solution

    see FolderBrowserDialog

    FolderBrowserDialog fd = new FolderBrowserDialog();
          if (fd.ShowDialog()==DialogResult.OK)                  
          textBox1.Text = fd.SelectedPath;
    LVL 6

    Expert Comment

    by:Neeraj Soni
    OpenFileDialog is not the right way to provide the user selecting the folder path, it is used for selecting the files only.

    FolderBrowserDialog is used for providing folder selecting functionality

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now