Jump to content

How to locate a user's My Documents folder in C++


Noggog

Recommended Posts

Heya,

 

I recently uploaded my mod Dynamic Leveled Lists, and I'm realizing the .exe that's included with it (that i wrote myself) is having issues finding the user's My Documents folders.

 

The code I wrote works for me, and it seems to work with MOST of everyone who has downloaded DLL. But I've gotten two or so complaints, and I'd like to find a better more reliable way to locate the folder.

 

As of now, here is my code that locates the My Documents folder (Yes, I'm fairly new to C++):

char pPath[250];
string DLLpath = "\\Documents\\My Games\\Oblivion\\Pluggy\\User Files\\DynamicLL.ini";
char* pPathInit = getenv ("USERPROFILE");
strcpy(pPath,pPathInit);

if (pPath!=NULL) {
      strcat(pPath,DLLpath.c_str());
cout << "Storing FormID data in: " << endl << pPath << endl << endl;
      outfile.open(pPath);
} else {

      // .... // Code dealing with when it fails to find the My Documents folder

}

Edited by Leviathan1753
Link to comment
Share on other sites

Hmm.. ive also tried doing this:

 

char pPath[250];
string DLLpath = "\\My Games\\Oblivion\\Pluggy\\User Files\\DynamicLL.ini";

SHGetSpecialFolderPath(NULL, pPath, CSIDL_MYDOCUMENTS, 0) ;
strcat(pPath,DLLpath.c_str());

Edited by Leviathan1753
Link to comment
Share on other sites

Still didn't work for a certain someone. It would label the documents folder "Documents" instead of the "My Documents" it should've been.

 

Any help would be appreciated.

 

I can't help you with the C++ functions, but in Windows Vista the local location IS 'Documents', not 'My Documents'. It can be found by %homepath%\Documents

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...