Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File explorer tool in Visual Studio?

I have a C# project using windows forms. I need to let the user enter the location of a text file, so they will need some way to browse files and folders i.e. a button that opens a file explorer. What tool (in the toolbox) would this be in Visual Studio 2010? I tried DirectoryEntry and DirectorySearcher but that just adds something to the bottom like this:

enter image description here

like image 994
Ayub Avatar asked Apr 09 '12 18:04

Ayub


People also ask

Where are the tools in Visual Studio?

To open the Visual Studio Installer, choose Tools, and then choose Get Tools and Features.... Then install the Visual Studio extension development workload.

How do I find the file path in Visual Studio?

In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.


1 Answers

It's not that easy. You want the file open dialog. You would have to add a button, then in the handler for the button open the dialog.

OpenFileDialog fdlg = new OpenFileDialog();
if(fdlg.ShowDialog() == DialogResult.OK)
{
// do something here with fdlg.FileName ;
}

source

like image 163
jarchuleta Avatar answered Oct 07 '22 06:10

jarchuleta