I want to save some file names for the user (e.g. recent files).
Let me use six sample files:
c:\Documents & Settings\Ian\My Documents\Budget.xlsc:\Documents & Settings\Ian\My Documents\My Pictures\Daughter Winning Goal.jpgc:\Documents & Settings\Ian\Application Data\uTorrentc:\Documents & Settings\All Users\Application Data\Consonto\SpellcheckDictionary.datc:\Develop\readme.txtc:\Program Files\Adobe\Reader\WhatsNew.txt
Now I hard-code the path to special folders. If the user redirects his folders, moves to another computer or updates his operating system, the paths will be split:
I want to be a good developer and convert these hard-coded absolute paths to relative paths from the corresponding special folders :
%CSIDL_Personal%\Budget.xls%CSIDL_MyPictures%\Daughter Winning Goal.jpg%CSIDL_AppData%\uTorrent%CSIDL_Common_AppData%\Consonto\SpellcheckDictionary.datc:\Develop\readme.txt%CSIDL_Program_Files%\Adobe\Reader\WhatsNew.txt
The difficulty is that for the same file there can be several views, for example:
c:\Documents & Settings\Ian\My Documents\My Pictures\Daughter Winning Goal.jpg%CSIDL_Profile%\My Documents\My Pictures\Daughter Winning Goal.jpg%CSIDL_Personal%\My Pictures\Daughter Winning Goal.jpg%CSIDL_MyPictures%\Daughter Winning Goal.jpg
Please note that in Windows XP My drawings are stored in My Documents :
%CSIDL_Profile%\My Documents
%CSIDL_Profile%\My Documents\My Pictures
But in Vista / 7 they are separated:
%CSIDL_Profile%\Documents
%CSIDL_Profile%\Pictures
: %CSIDL_xxx%\filename.ext ; Windows . . , , , , CSIDL , :
CSIDL_Personal \Budget.xls
CSIDL_MyPictures \Daughter Winning Goal.jpg
CSIDL_AppData \uTorrent
CSIDL_Common_AppData \Consonto\SpellcheckDictionary.dat
-1 c:\Develop\readme.txt (-1, since 0 is a valid csidl)
CSIDL_Program_Files \Adobe\Reader\WhatsNew.txt
, , , ?
:
void CanonicalizeSpecialPath(String path, ref CSLID cslid, ref String relativePath)
{
return "todo";
}
.