Board index » cppbuilder » Clean up my filepath
Thorsten Kettner
![]() CBuilder Developer |
Thorsten Kettner
![]() CBuilder Developer |
Clean up my filepath2006-02-15 03:14:19 PM cppbuilder0 Hi all, I have a string containing path and name of a file, like this: "C:\Dir1\Dir2\Dir3\..\..\SomeFile.ext". The path is correct and I can access the file, but I would like to clean up the path for diplay, i.e.: "C:\Dir1\SomeFile.ext". I know it wouldn't be to hard to do the string manipulations myself, but I am too lazy and also quite curious if I could just ask the system for the clean path. Is there a command or a series of commands that gives/give me the cleaned up path? |
SF
![]() CBuilder Developer |
2006-02-15 04:29:49 PM
Re:Clean up my filepathQuoteI have a string containing path and name of a file, like this: Stefano. |
Vladimir Stefanovic
![]() CBuilder Developer |
2006-02-15 04:45:49 PM
Re:Clean up my filepath
Also look at BCB6/VCL Help for MinimizeName()
-- Best regards, Vladimir Stefanovic {smallsort} |
Thorsten Kettner
![]() CBuilder Developer |
2006-02-15 06:46:01 PM
Re:Clean up my filepath
"Thorsten Kettner" wrote something like:
QuoteConvert path "C:\Dir1\Dir2\Dir3\..\..\SomeFile.ext" to glad though you mentioned the functions for two reasons. First: You pointed me to PathCompactPath. That made me look at shlwapi path functions. Thus I found PathCanonicalize, which is what I had been looking for. Second: I didn't know about MinimizeName and PathCompactPath and coded something alike in another project which I can replace now by a mere function call. Explanation of what I was looking for: The path "C:\Dir1\Dir2\Dir3\..\..\SomeFile.ext" means exactly the same as "C:\Dir1\SomeFile.ext", because "\.." means: go up one directory. If one interprets the path to find out where SomeFile.ext is located, it goes like this: Go to C:\, then go down to Dir1, then down to Dir2, then down to Dir3, then one dir up (to Dir2), then one dir up (to Dir1). I wanted the system to state that the path "C:\Dir1\Dir2\Dir3\..\..\SomeFile.ext" means nothing else but simply "C:\Dir1\SomeFile.ext". |
SF
![]() CBuilder Developer |
2006-02-15 08:40:58 PM
Re:Clean up my filepathQuoteExplanation of what I was looking for: Stefano. |