I have some legacy data that was created on Windows XP. It contains absolute file names to files in users’ My Documents directories. On Windows 7, these absolute references are no longer point to the correct place. For example what was “C:\Documents and Settings\Gareth\My Documents\readme.txt” should now be “C:\Users\Gareth\Documents\readme.txt”.
Many Win32 functions are happy to take the file names under “C:\Documents and Settings” and to behind the scenes convert them to the new file names, however there are functions we use that don’t do this. Is there a Windows API that I can use to convert these file names to the new locations?
Obviously, I could do string search and replace, but that wouldn’t be guaranteed to work under all circumstances. Because there are Windows functions that seem to do the substitution it feels like there ought to be a published function I can call to do the same thing.
Just to clarify my question: I’m looking for a function that does this:
Input: “C:\Documents and Settings\Gareth\My Documents\readme.txt”
Output: “C:\Users\Gareth\Documents\readme.txt”
or
Input: “C:\Documents and Settings\Gareth\My Documents\”
Output: “C:\Users\Gareth\Documents\”
This works with symbolic links. That should work on any function that takes a path, MSDN documentation is here: msdn.microsoft.com/en-us/library/aa365680%28v=VS.85%29.aspx
I verified MapFileAndCheckSum(), it works fine. Windows7, compiled with UNICODE in effect.