title: Regular expression to disallow special characters that are invalid in a Windows Folder name
body: <p>I have a C# .Net MVC 3 web app.  I am needing to decorate a property with a RegEx data annotation that conforms to the rules for a windows folder name.  The invalid characters are: \, /, *, : , ? , “, &lt;, >, |</p>
  
  <p>I'm not a greate RegEx developer and I've tried a few RegEx's but they have all disallowed the - character which our app needs to allow.</p>
  
  <p>I have tried:</p>
  
  <pre><code>^[a-zA-Z0-9]+(([_][a-zA-Z0-9])?[a-zA-Z0-9]*)*$
  
  ^[a-zA-Z''-'\s]{1,40}$
  
  ^( [a-zA-Z] )( ( [a-zA-Z_\-\s0-9\.\)\(] )( [^\\!@#$%^&amp;/:*?&lt;&gt;""|]* ) )*$
  </code></pre>
  
  <p>Valid:</p>
  
  <pre><code>MyFilemane-!@#$%^&amp;
  </code></pre>
  
  <p>Invalid:</p>
  
  <pre><code>MyFilename|
  MyFileName\
  </code></pre>