Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a Browse Button 1

Status
Not open for further replies.

natwod

Programmer
Nov 21, 2002
41
US
Hi, I'm new at C# and I was wondering if there is an easy (built-in) way to make a browse button, which opens up a browse window and returns the pathname to a file.

Anybody?

Thanks!
Natwod

--The Black Dragon
 
Yep it is fairly easy:

Code:
OpenFileDialog ofdMyDialog = new OpenFileDialog();

ofdMyDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
ofdMyDialog.CheckFileExists = true;

string strFileName = string.empty;
if (ofdMyDialog.ShowDialog() == DialogResult.OK)
{
// They clicked the ok button, should have a pathname here
strFileName = ofdMyDialog.FileName;
}

Skute

"There are 10 types of people in this World, those that understand binary, and those that don't!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top