How To use openFile Dialog value in two button click

Posted by Anishabathija under C# on 12/13/2012 | Points: 10 | Views : 1041 | Status : [Member] | Replies : 0
Hey I have two buttons , One Browse which when i click I browse the file i want.
the code is as follows:
private void button1_Click(object sender, EventArgs e)
OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.Title = "Browse File";

if (openFileDialog1.ShowDialog() == DialogResult.OK)
txtFile.Text = openFileDialog1.FileName;

now on clicking the next button I want to pass the above file to this button so I can perform my operation

if (openFileDialog1.CheckFileExists)

string SelectedFile = openFileDialog1.FileName;

but its throwing an error saying

Empty path name is not legal.:

Please help.
Urgent !!


(No response found.)

Login to post response