title: Openfiledialog filter doesn't restrict files to open by typing full file path in File name text box C# winform
body: <p>I am using the <code>OpenFileDialog</code> to open some specific file type, to do that I set the <code>Filter</code> property of <code>OpenFileDialog</code>. The filter setting does only hiding the file which are out of filter extensions, but user can still select  those files by typing the file name in <code>OpenFileDialog</code> 'File Names:' text box. 
  I want user should not be able to select the file which are out of filter settings even typing the path manually in openFileDialog box 'File Names:' textbox.</p>
  
  <p>This is the code.</p>
  
  <pre><code>    private void button7_Click(object sender, EventArgs e)
      {
          EncryptFile();
      }
  
      public void EncryptFile()
      {
          OpenFileDialog dialog = new OpenFileDialog();
          dialog.Filter = "Office Files|*.doc;*.xls;*.ppt";
          dialog.InitialDirectory = @"C:\";
          dialog.Title = "Please select an office file to encrypt.";
          string fileName = "";
          if (dialog.ShowDialog() == DialogResult.OK)
          {
  
              fileName = dialog.FileName; 
              /// doing something
          }
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AQG43.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AQG43.png" alt="enter image description here"></a></p>