[DllImport("shlwapi.dll", CharSet = CharSet.Auto)]
static extern bool PathIsRelative([In] string lpszPath);
Declare Function PathIsRelative Lib "shlwapi.dll" (TODO) As TODO
None.
None.
None.
Please add some!
[DllImport("shlwapi.dll", CharSet = CharSet.Auto)] static extern bool PathIsRelative([In] string lpszPath);
public static bool IsRelativePath(string path)
{
return PathIsRelative(path);
}
//unit test
[Test]
public void TestIsRelative()
{
Assert.AreEqual(true,IO.IsRelativePath(@"test.txt"),"Test 1");
Assert.AreEqual(true, IO.IsRelativePath(@"..\test.txt"), "Test 2");
Assert.AreEqual(true, IO.IsRelativePath(@"..\..\test.txt"), "Test 3");
Assert.AreEqual(false, IO.IsRelativePath(@"C:\test.txt"), "Test 4");
}