title: Check if a string is a valid Windows directory (folder) path
body: <p>I am trying to determine whether a string input by a user is valid for representing a path to a folder. By valid, I mean formatted properly.</p>
  
  <p>In my application, the folder represents an installation destination. Provided that the folder path <em>is</em> valid, I want to determine if the folder exists, and create it if it does not.</p>
  
  <p>I am currently using <code>IO.Directory.Exists( String path )</code>. I find that this works fine except when the user does not format the string properly. When that happens, this method will return false which indicates that the folder does not exist. But this is a problem because I won't be able to create the folder afterwards.</p>
  
  <p>From my googling I found a suggestion to use a regular expression to check if the format is proper. I have no experience with regular expressions, and am wondering if that is a viable approach. Here's what I found:</p>
  
  <pre><code>Regex r = new Regex( @"^(([a-zA-Z]\:)|(\\))(\\{1}|((\\{1})[^\\]([^/:*?&lt;&gt;""|]*))+)$" );
  return r.IsMatch( path );
  </code></pre>
  
  <p>Would a regular expression test in combination with <code>Directory.Exists()</code>, give me a <em>good enough</em> method to check if the path is valid and whether it exists? I know this will vary with the OS and other factors, but the program is targeted for <strong>Windows</strong> users only.</p>