I code therefore I am.

August 24, 2009 at 2:54pm
0 notes
Comments (View)
home

Tags:
CSharp  

System.IO.Path.Combine Behavior

When using Path.Combine, you should be aware of the behavior that if the second parameter has a leading slash, it will ignore the first parameter.

Given the following:

string root = "c:\";
string path = "test.txt";
string lead = "\test.txt";

We get the following results:

using System.IO;

Path.Combine(root, path); // ‘c:\test.txt’
Path.combine(root, lead); // ‘\test.txt’

blog comments powered by Disqus