code_junkie

Best place to put application data?

Nov 11th, 2011
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
  2.  
  3. // assumes
  4. // company is a pointer to a character sting containing company name
  5. // appname is a pointer to a character string containing application name
  6. // fname is a pointer to a character string cintaining name of file to be created
  7.  
  8. #include <shlobj.h> // for SHGetFolderPath
  9. #include <direct.h> // for _mkdir
  10.  
  11. char path[MAX_PATH];
  12. SHGetFolderPath(NULL,CSIDL_COMMON_APPDATA,NULL,NULL,path);
  13. strcat(path,"/");
  14. strcat(path,company);
  15. _mkdir(path);
  16. strcat(path,"/");
  17. strcat(path,appname);
  18. _mkdir(path);
  19. strcat(path,"/");
  20. strcat(path,fname);
  21.  
  22. // path is now a character string which can passed to fopen
Add Comment
Please, Sign In to add comment