   Problem with GetFullPathName...
  Ok, this is going to be hard to explain, but i'll try :Let's say I have this directory structure : c:|TestMap|First ----- Second ----- Third ----- Fourth|  -bFirst I saved all the directory names in a "queue".  My problem is when I use the names to get to path (via GetFullPathName(...) I don't get the right path names!!Now I finally found out it has something to do with my "current directory".Let's say my "current directory" is c:\TestMap\First.  When I use GetFullPathName to find the path of "Second" I get : c:\TestMap\First\Second, while it should be c:\TestMap\Second !!Is there something I can do about that ??thanks...   [edited by - HolyFish on August 2, 2003 9:38:00 AM][edited by - HolyFish on August 2, 2003 9:38:21 AM][edited by - HolyFish on August 2, 2003 9:39:19 AM]
GetFullPathName() will, provided you pass it the proper parameters, fill lpBuffer with [current drive] + [current directory] + [whatever you pass for lpFileName].  The file doesn''t even have to exist.In your example, GetFullPathName() seems to be working perfectly.  If "C:" is the current drive, and "TestMap\First" is the current directory, and you pass "second" as the lpFileName parameter it should return this string: "C:\TestMap\First\second".;  First of all, thanks for the reply !!quote:Original post by Solo  GetFullPathName() will, provided you pass it the proper parameters, fill lpBuffer with [current drive] + [current directory] + [whatever you pass for lpFileName].  The file doesn''t even have to exist.In your example, GetFullPathName() seems to be working perfectly.  If "C:" is the current drive, and "TestMap\First" is the current directory, and you pass "second" as the lpFileName parameter it should return this string: "C:\TestMap\First\second". Yes, I figured that out  but that''s just the thing that may NOT happen !!Here is an other example...Let''s say I know a name of a certain directory : "MyDir".  And his path is : "c:\TestMap\ADirectory\AnotherDir\FinalDir\MyDir".Let''s say my current directory is set to "c:\" (via SetCurrentDirectory("c:\")).  When I use GetFullPathName("MyDir", BUFFER_LENGTH, MyBuffer, NULL); then the path I get in return is : "c:\MyDir", while it should be : "c:\TestMap\ADirectory\AnotherDir\FinalDir\MyDir"I don''t know why he gives me this path (the path doesn''t even exist !!)Is there no way to get the REAL path of a certain directory ??thanks...;quote:Let''s say my current directory is set to "c:\" (via SetCurrentDirectory("c:\")). When I use GetFullPathName("MyDir", BUFFER_LENGTH, MyBuffer, NULL); then the path I get in return is : "c:\MyDir", while it should be : "c:\TestMap\ADirectory\AnotherDir\FinalDir\MyDir"c:\MyDir is correct."C:" is the current drive.  "\" is the current directory.  lpFileName is "MyDir".[current drive] + [current directory] + [whatever you pass for lpFileName] = "C:\MyDir"And like I said, the file or path doesn''t even have to exist.The name of the function is throwing you off.  It doesn''t ''find'' the full path of a file or directory.  It creates a string that contains a full path based on the current drive, directory, and file name/path name you pass.  Basically, it just concatenates strings. ;quote:Original post by Solo  The name of the function is throwing you off.  It doesn''t ''find'' the full path of a file or directory.  It creates a string that contains a full path based on the current drive, directory, and file name/path name you pass.  Basically, it just concatenates strings.   Damn, that''s a pitty...The function name got me confused there...Is there another way to search for the real path of a certain directory ??;quote:Original post by HolyFish  Here is an other example...Let''s say I know a name of a certain directory : "MyDir".  And his path is : "c:\TestMap\ADirectory\AnotherDir\FinalDir\MyDir".Let''s say my current directory is set to "c:\" (via SetCurrentDirectory("c:\")).  When I use GetFullPathName("MyDir", BUFFER_LENGTH, MyBuffer, NULL); then the path I get in return is : "c:\MyDir", while it should be : "c:\TestMap\ADirectory\AnotherDir\FinalDir\MyDir"Windows (and most other OS:es) allow files in different directories to have the same name. How would it know which one you are looking for?Example:c:\aaa\readme.txtc:\bbb\readme.txtc:\ccc\readme.txtCurrent drive:c:Current dir:\What would GetFullPathName("readme.txt", ...) return?   [How To Ask Questions|STL Programmer''s Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN] 