I would like to open the openFileDialog at the click of a button. But all my efforts are unsuccessful.
I tried this:
private void button1_Click(object sender, EventArgs e)
{
var dialog = new OpenFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
Class1 excel = new Class1(dialog.InitialDirectory, 1);
string path = dialog.InitialDirectory + ".txt"; //this is to create a text document with the same name
TextWriter tw = new StreamWriter(path, true);
tw.Write(excel.ReadCell(0, 0));
tw.Close();
}
}
There always seems to be something going on but the window disappears right away.
Does anyone know your advice?
Thanks