title: What is the best way to combine a path and a filename in C#/.NET?
body: <p>What is the best way to combine a path with a filename?</p>
  
  <p>That is, given <code>c:\foo</code> and <code>bar.txt</code>, I want <code>c:\foo\bar.txt</code>.</p>
  
  <p>Given <code>c:\foo</code> and <code>..\bar.txt</code>, I want either an error or <code>c:\foo\bar.txt</code> (so I cannot use <code>Path.Combine()</code> directly). Similarly for <code>c:\foo</code> and <code>bar/baz.txt</code>, I want an error or <code>c:\foo\baz.txt</code> (not <code>c:\foo\bar\baz.txt</code>).</p>
  
  <p>I realize, I could check that the filename does not contain '\' or '/', but is that enough? If not, what is the correct check?</p>