Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Application Data Directory

Not completely a programming question, but its close enough so here goes:

In Mac OS I'll put user-specific files for my app in ~/Library/Application Data/{MyApp}/ and in *nix I'll put them in ~/.{MyApp}/ - where should I put them for Windows?

I'll be using Ruby's File.expand_path to get to this directory, so if there's a windows equivalent of ~ then that's fine.

(Answers for Windows XP, Vista and 7 would be appreciated if they're not the same)

like image 477
JP. Avatar asked Apr 06 '10 21:04

JP.


1 Answers

The way the do this on Windows is to use the ApplicationData environment variable. If you were using C# you can get the folder it maps to using System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), googling for the Ruby equivalent it's ENV['APPDATA']. In English-language Windows it maps to:

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

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

It may map to a different folder in other languages, but as long as you get the directory from the environment variable and not hard-code it then it doesn't really make a difference. If you create a folder in there for your app and store the data there, Vista and 7 will allow read and write access to it without giving UAC prompts.

like image 149
Michael Low Avatar answered Nov 03 '22 16:11

Michael Low