title: Validate folder name in C#
body: <p>I need to validate a folder name in c#. </p>
  
  <p>I have tried the following regex : </p>
  
  <pre><code> ^(.*?/|.*?\\)?([^\./|^\.\\]+)(?:\.([^\\]*)|)$
  </code></pre>
  
  <p>but it fails and I also tried using <code>GetInvalidPathChars()</code>. </p>
  
  <p>It fails when i try using <code>P:\abc</code> as a folder name i.e <code>Driveletter:\foldername</code></p>
  
  <p>Can anyone suggest why?</p>