# Cleaning a path

## Recommended Posts

Does anyone know of a nice little function that cleans a directory structured path, such as this..
C:\DirA\DirB\..\DirC\..\DirB\DirD\..\..\DirB\X
Which could be cleaned up to
C:\DirA\DirB\X
I know it's as simple as backtracking to the last slash for each ..\, but I would rather use a standard function if such a thing exists? Thanks for help.

##### Share on other sites
For Windows you can use PathCanonicalize.

This requires IE 4.0 on Win95/NT 4.0 (which can still be an issue).

##### Share on other sites
Ahh, thanks. I'm wondering if this function can use the same string buffer for destination and source. Doesn't say anything in the docs. I would guess that means no.

Very strange that such a simple task requires internet explorer. Microsoft keeps me guessing [evil]

Thanks again.

##### Share on other sites
Quote:
 Original post by Jiia...snip...Very strange that such a simple task requires internet explorer. Microsoft keeps me guessingThanks again.

Yeah, they kept adding a lot of neat stuff using IE to basically update Windows. Thank god they stopped doing that again.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628333
• Total Posts
2982130

• 24
• 9
• 9
• 13
• 11