<p>In .NET is there a function that tests if a string is syntactically a correct path? I specifically don't want it to test if the path actually exists.</p>

<p>my current take on this is a regex:</p>

<pre><code>([a-zA-Z]:|\\)?\\?([^/\\:*?"&lt;&gt;|]+[/\\])*[^/\\:*?"&lt;&gt;|]*
</code></pre>

<p>matches:</p>

<pre><code>c:\
bbbb
\\bob/john\
..\..\
</code></pre>

<p>rejects:</p>

<pre><code>xy:
c:\\bob
</code></pre>

I'd suggest just using a regex for this since you specifically don't want to test if the path exists.
Here's something
google helped me dig up
:
```
```
RegEx="^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$"
```
```
You could combine this with System.IO.Path.GetInvalidPathChars() method and make the regex dynamically exclude all of the invalid characters.