R – As a developer, how should I use the special folders in Windows Vista (and Windows 7)

special-folderswindows 7windows-vista

Where should I save data related to my application? Where should I save configuration files? Where should I save temporary files? Should I do it in "Documents"? "AppData"? Etc…

What is the best practice for saving data to the disk (I guess, best practice for special folders?!)?

Best Answer

ApplicationData: Everything that your application needs as "per user" data and does not fall under other categories. Standard configuration files would go here.

CommonApplicationData: Everything that is not "per user" data.

LocalApplicationData: Data that is per user and non-roaming. For example, everything where you want to ENSURE that it is only stored on this machine (like machine activation codes, often also cache/temporary data). Standard temporary files would go here.

MyDocuments: User data that the user actually would identify as "recognizable single documents".

If you don't care about the filename, you can also use a tempfile API to generate a temporary file in the temp directory. You should NOT do this manually. In, for example, .NET you can use Path.GetTempFileName() for that purpose.

Related Topic