title: How to restrict special characters in File Dialog's file name in C#?
body: <p>My scenario is, need to restrict the selection of file in an <code>OpenFileDialog</code>, when there exists any special characters like #,%,+, -.</p>
  
  <p>I can validate the file name after selecting file by the following code.  </p>
  
  <pre><code>Nullable&lt;bool&gt; result = dlg.ShowDialog();
  
  if (result == true)
  {
     if(dlg.SafeFileName.Contains("#") || dlg.SafeFileName.Contains("+")
     {
       // show error message;
       // Open file dialog again;   
     }
  }
  </code></pre>
  
  <p>Is there any way to validate the file name without closing the dialog?</p>
  
  <p>Thanks in advance.</p>