Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

PathCombine (shlwapi)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("shlwapi.dll", CharSet=CharSet.Auto)]
static extern string PathCombine([Out] StringBuilder lpszDest, string lpszDir, string lpszFile);

VB Signature:

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

Notes:

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.

Tips & Tricks:

Please add some!

Sample Code:

    [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");

    }

Alternative Managed API:

Path.Combine

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions