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:
To open the Visual Studio Installer, choose Tools, and then choose Get Tools and Features.... Then install the Visual Studio extension development workload.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With