title: Open, select and add a .jpg file inside a form
body: <p>How to open, select and add a only jpeg format file inside a form in c# from any directory of computer? Here is the code.</p>
  
  <pre><code>private void open2ToolStripMenuItem_Click(object sender, EventArgs e)
  {
      pictureBox1.Visible = true;
      string Chosen_File = "";    
      Chosen_File = openFileDialog1.FileName;          
      openFileDialog1.Title = "Insert an image";   
      openFileDialog1.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
      openFileDialog1.FileName ="";
      openFileDialog1.Filter = "JPEG Images|*.jpg|GIF Images|*.gif|All Files|";
      openFileDialog1.ShowDialog();
      if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
      {
          Chosen_File = openFileDialog1.FileName;
          pictureBox1.Image = Image.FromFile(Chosen_File);
  
      }
   }
  </code></pre>