-2

I am creating a windows form with the openFileDialog and the showFileDialog icons. But when I run the form, I do not see the options in the top left corner. Is there some properties that I need to change to visible or something? Any help will be appreciated.

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93

1 Answers1

6

These Dialog are not shown unless you perform any action (either clicking a save button or open file Button) what you need to do create a button and then handle its click event something like this.

  this.button1.Click += new System.EventHandler(this.button1_Click);

and then in this event, you can invoke your dialog

private void button1_Click(object sender, EventArgs e)
{
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
         string filename = openFileDialog1.FileName; // this is the selected file
    }
}
Pankaj
  • 2,618
  • 3
  • 25
  • 47