Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between PathAppend and PathCombine in Win32 API

Tags:

c++

path

winapi

I want to understand what's the difference between those functions, and which of them should I use for work with paths?

For example: I want "C:\Temp" + "..\Folder" = "C:\Folder"

Thanks

like image 287
SlavaNov Avatar asked Dec 02 '10 19:12

SlavaNov


2 Answers

PathCanonicalize() might be worth mentioning, in case the strings are already concatenated.

like image 129
Hans Passant Avatar answered Sep 28 '22 01:09

Hans Passant


You have to use PathCombine for this.

Concatenates two strings that represent properly formed paths into one path; also concatenates any relative path elements.

PathAppend specifically rules out relative path qualifiers, per the MSN docs:

The path supplied in pszPath cannot begin with "..\" or ".\" to produce a relative path string.

like image 45
Steve Townsend Avatar answered Sep 28 '22 03:09

Steve Townsend