Use the OpenFile Dialog to open files.
Something like this:
OpenFileDialog dlgOpenReciprocityFile = new OpenFileDialog ( );dlgOpenReciprocityFile.InitialDirectory = @"C:\";
dlgOpenReciprocityFile.Filter = "text Files (*.txt)|*.txt|All Files (*.*)|*.*";
dlgOpenReciprocityFile.FilterIndex = 1;
dlgOpenReciprocityFile.RestoreDirectory = true;if ( dlgOpenReciprocityFile.ShowDialog ( ) == DialogResult.Cancel )
{
comboStateList.Visible = false;
this.labelCurrentStatus.Text = "Ready . . .";
ResetButtons ( true, false, true );
dlgOpenReciprocityFile.Dispose ( );
}
else
{
try
{
//* initialize the file path variable
fileControl.m_InFilePath = dlgOpenReciprocityFile.FileName; //* open the file
fi_inputFile = new FileInfo ( fileControl.m_InFilePath ); //* create a text reader
srReciprocityReader = fi_inputFile.OpenText ( );
}
catch
{
<your message box.show statements here>
}
insertthe aboveinto your button click method (using your own variable names).