<p>How do I pull out the filename from a full path using regular expressions in C#?</p>

<p>Say I have the full path <code>C:\CoolDirectory\CoolSubdirectory\CoolFile.txt</code>.</p>

<p>How do I get out CoolFile.txt using the .NET flavor of regular expressions? I'm not really good with regular expressions, and my RegEx buddy and me couldn't figure this one out.</p>

<p>Also, in the course of trying to solve this problem, I realized that I can just use  <code>System.IO.Path.GetFileName</code>, but the fact that I couldn't figure out the regular expression is just making me unhappy and it's going to bother me until I know what the answer is.</p>

Why must you use regular expressions? .NET has the built-in
```
Path.GetFileName()
```
method specifically for this which works across platforms and filesystems.