[Last Call] Learn how to a build a cloud-first strategyRegister Now


C# and select a directory

Posted on 2005-05-06
Medium Priority
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

Fahad Mukhtar earned 800 total points
ID: 13949672
see FolderBrowserDialog

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

Expert Comment

by:Neeraj Soni
ID: 13950560
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

831 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