Windows Application Data Catalog

Not really a programming issue, but it's close enough, like this:

On Mac OS, I put the user files for my application in ~/Library/Application Data/{MyApp}/ and in * nix I put them in ~/.{MyApp}/ - where should I put them for Windows?

I will use Ruby File.expand_path to access this directory, so if there is a Windows equivalent ~ , then this is fine.

(Answers for Windows XP, Vista and 7 will be evaluated if they do not match)

+6
windows ruby settings
source share
3 answers

How to do this on Windows, you need to use the ApplicationData environment variable. If you used C #, you can get the folder that it maps using System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) , googling for the Ruby it ENV['APPDATA'] equivalent ENV['APPDATA'] . In English-speaking Windows, it maps to:

C:\Users\%username%\AppData\Roaming\ (on Vista and Windows 7)

C:\Documents and Settings\%username%\Application Data\ (In XP)

It may appear in another folder in other languages, but as long as you get the directory from the environment variable, and not from the hard code, it does not really matter. If you create a folder for your application and save the data there, Vista and 7 will allow read and write access without providing UAC prompts.

+3
source share

Offline, I'm not sure how Ruby handles expand_path in ~ for Windows. Windows has features like SHGetSpecialFolderPath and SHGetSpecialFolderLocation for this kind of thing. It would seem, obviously, to use one of them for expand_path, but I do not know if it is sure.

0
source share

For Vista and Windows 7 and Windows XP

  char appdir[MAX_PATH]; size_t requiredSize; errno_t err= getenv_s( &requiredSize, appdir, MAX_PATH, "appdata" ); 

seems simpler than using legacy APIs or those that don't work on Windows XP.

0
source share

All Articles