PathIsRelative (shlwapi)
Last changed: ehaddan-173.11.6.57

.
Summary
Returns TRUE if the path is relative, or FALSE if it is absolute.

C# Signature:

[DllImport("shlwapi.dll", CharSet = CharSet.Auto)]
static extern bool PathIsRelative([In] string lpszPath);

VB Signature:

Declare Function PathIsRelative Lib "shlwapi.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    [DllImport("shlwapi.dll", CharSet = CharSet.Auto)] static extern bool PathIsRelative([In] string lpszPath);
    public static bool IsRelativePath(string path)
    {
        return PathIsRelative(path);
    }

    //nunit 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");
    }

Documentation