[DllImport("shlwapi.dll", CharSet=CharSet.Auto)]
static extern string PathCombine([Out] StringBuilder lpszDest, string lpszDir, string lpszFile);
Declare Function PathCombine Lib "shlwapi.dll" (TODO) As TODO
This is similar, but not identical, to PathAppend and Path.Combine. For example, combining "C:\foo" with "\bar" yields "C:\bar" rather than "C:\foo\bar" or "\bar" respectively.
Please add some!
[DllImport("shlwapi.dll", CharSet = CharSet.Auto)]
static extern string PathCombine([Out] StringBuilder lpszDest, string lpszDir, string lpszFile);
public static string GetAbsolutePath(string basePath, string relativePath)
{
StringBuilder sb = new StringBuilder();
string result = PathCombine(sb,basePath,relativePath);
return result;
}
//nunit test case
[Test]
public void TestGetAbsolutePath()
{
Assert.AreEqual(@"c:\abc\123.txt",IO.GetAbsolutePath(@"c:\abc\","123.txt"),"Test 1");
Assert.AreEqual(@"c:\abc\123.txt", IO.GetAbsolutePath(@"c:\abc\efg\", @"..\123.txt"), "Test 1");
}