Difference between 'SpecialFolder.LocalApplicationData' and 'SpecialFolder.ApplicationData'?
Asked Answered
T

3

61

On my system, %AppData% leads to ApplicationData which is C:\Users\<USER>\AppData\Roaming

But there is also C:\Users\<USER>\AppData\Local
And for some more confusion D:\Users\<USER>\AppData\LocalLow

string local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string roaming = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

My question is, to which of these locations should my application save its data?

Are there guidelines for which of these locations to use? And am I leaving myself open to problems if I choose the wrong location?

Telega answered 14/3, 2012 at 19:56 Comment(1)
The Roaming folder is most commonly used to store data. I don't know the actual difference.Satrap
C
71

The Roaming folder is copied between machines when roaming profiles are enabled (in a domain environment). Use it for application data that you want to share between machines. But don't store large files in there -- IT departments don't like it when you do that, and it increases the time taken for the user to log in and to log out as the files are copied around.

The Local folder is not copied between machines. Use it for application data that's specific to a machine.

The LocalLow folder is used for low-privilege tasks (such as Internet Explorer). You shouldn't need to worry about it.

For files that the user specifically saved, you should put them (by default) in the Documents folder.

Clytemnestra answered 14/3, 2012 at 20:3 Comment(2)
Any thoughts on how these folders are used for a Windows 8 user that is logged onto the machine with a Microsoft account? Is a Windows 8 app just a completely different beast, with its own APIs, etc., and the folders used are different / mediated by an API? Is a Windows 8 user logged on with a MS account a "roaming user"?Solleret
will the roaming folder also work if the computer isn't in a domain at all?Squeaky
C
12

According to MSDN the difference is that LocalApplicationData stays on the local machine and does not roam... ApplicationData does roam for example if the user logs onto the domain from a different computer it will be synced...

The LocalLow refers to specific situations likea BHO running in "Protected Mode" of IE...

For a standard application always use ApplicationData. Use LocalApplicationData for things that should NOT roam with the user...

Chuckle answered 14/3, 2012 at 20:2 Comment(0)
B
7

From MSDN - Environment.SpecialFolder Enumeration:

ApplicationData - The directory that serves as a common repository for application-specific data for the current roaming user. A roaming user works on more than one computer on a network. A roaming user's profile is kept on a server on the network and is loaded onto a system when the user logs on.

LocalApplicationData The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.

In short, use ApplicationData for roaming profiles, and LocalApplicationData for non roaming profiles.

Bomarc answered 14/3, 2012 at 20:3 Comment(1)
Nicely summarized through an official doc reference. Should be very helpful for readers.Jelks

© 2022 - 2024 — McMap. All rights reserved.