title: OpenFileDialog opening twice in my C# program
body: <p>I am having a problem with a with a code that I used for my C# application. When I click on the browse button and select the file dialogue box opens twice.</p>
  
  <pre class="lang-cs prettyprint-override"><code>private void txt_location_TextChanged(object sender, EventArgs e) 
  {
      string folderPath = "";
      FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
      if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) {
          folderPath = folderBrowserDialog1.SelectedPath;
      }
  }
  
  private void Button21_Click(object sender, EventArgs e) 
  {
      using(var fbd = new FolderBrowserDialog()) {
          DialogResult result = fbd.ShowDialog();
  
          if (result == DialogResult.OK &amp;&amp; !string.IsNullOrWhiteSpace(fbd.SelectedPath)) {
              selectedPath = fbd.SelectedPath;
              txt_location.Text = selectedPath;
          }
      }
  }
  
  private void bunifuThinButton21_Click_1(object sender, EventArgs e) 
  {
      System.IO.StreamWriter file;
      bool isvalid = ValidateInputs();
      try {
          file = new System.IO.StreamWriter(selectedPath + @ "\dred.txt");
  
          catch (Exception ex) {
              MessageBox.Show("Please, Select valid Path..");
              return;
          }
          try {
              if (isvalid) {
                  WriteLines(file);
              }
          } 
          catch (Exception ex2) {
             MessageBox.Show(ex2.Message);
          } 
          finally {
              file.Close();
          }
      }
  }
  </code></pre>
  
  <p>Obviously, it is only meant to open once to enable me to read the selected file. This works, but only once I have selected the file twice.</p>
  
  <p>Thanks in advance for your help.</p>