A
AMP
Hello,
I have the following code in a menu function.
If no fileis clicked (Cancel) it throws an exception.I try to write a
catch try catch statement but opnFile is not visable in the catch
statement I just want to close the dialog box if the user doesnt pick a
file.I thought "Cancel" would just make it go away, but noooo.I will
need "filename" for the next operation if they choose one.
Help Please
OpenFileDialog opnFile = new OpenFileDialog();
opnFile.Filter = "txt files (*.txt)|*.txt|All files
(*.*)|*.*";
opnFile.ShowDialog();
filename = opnFile.FileName;
// StreamReader openReader = new
StreamReader(openStream);
textBox4.Text = File.ReadAllText(opnFile.FileName);
this.button3.Enabled = true;
Thanks
Mike
I have the following code in a menu function.
If no fileis clicked (Cancel) it throws an exception.I try to write a
catch try catch statement but opnFile is not visable in the catch
statement I just want to close the dialog box if the user doesnt pick a
file.I thought "Cancel" would just make it go away, but noooo.I will
need "filename" for the next operation if they choose one.
Help Please
OpenFileDialog opnFile = new OpenFileDialog();
opnFile.Filter = "txt files (*.txt)|*.txt|All files
(*.*)|*.*";
opnFile.ShowDialog();
filename = opnFile.FileName;
// StreamReader openReader = new
StreamReader(openStream);
textBox4.Text = File.ReadAllText(opnFile.FileName);
this.button3.Enabled = true;
Thanks
Mike