Oct 14, 2008

Tricky Path.Combine Thing

About 10 minutes I needed to understand the problem. Luckily I had tests. It appears, that Path.Combine works funny. Here are a comple of examples:

  1. If you do Path.Combine("../Tests/", "/123.xml") the result will be "/123.xml"
  2. If you do Path.Combine("../Tests/", "123.xml") the result will be "../Tests/123.xml"
  3. Finally, if you do Path.Combine("../Tests", "123.xml") the result will be "../Tests\123.xml"

Oh, frankly speaking, I would really like to have Path.Combine("../Tests/", "/123.xml")  give me "../Tests/123.xml" or, at least, "../Tests//123.xml" and even "../Tests\123.xml" would be fine.

For now, I have to remember funny point #1 and will try to do #2 and #3 all along.

No comments: