Getting local My Documents folder path
- by smsrecv
In my C++/WinAPI application I get the My Documents folder path using this code:
wchar_t path[MAX_PATH];
SHGetFolderPathW(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,path);
One of the users runs my program on a pc connected to his corporate network. He has the My Documents folder on a network. So my code returns something like
\paq\user.name$\My Documents
Though he says he has a local copy of My Documents.
The problem is that when he 'swaps VPN', the online My Documents becomes unavailable and my program crashes with the system error code 64 "The specified network name is no longer available" ( it tries to write to the file opened in the online my docs folder).
How can I always get the local My Documents folder path using C++/WinAPI?