Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use 'ApplicationData' or 'LocalApplicationData' to store a file common to all users?

Tags:

c#

.net

.net-3.5

Summary: Several different users will use my application on a specific machine. I want the application to store its data in a single common file on this machine regardless of which user is running the application.

To achieve what I want, I am wondering whether this question might be relevant: Difference between 'SpecialFolder.LocalApplicationData' and 'SpecialFolder.ApplicationData'?

From that question and its answers it appears that:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) 

is specific to the machine. Some of the information I have turned up by googling confirms that. However, I have also found information that says that LocalApplicationData is user specific.

So, which is true? And can anyone tell me what is really meant by "user specific" and "machine specific"?

Here's what I'm thinking: If LocalApplicationData is machine specific, then I can use that as a basis for having my application save all of its data to a single common file for all users.

I'm also wondering about the ApplicationData folder:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Should I instead use ApplicationData to get what I want?

like image 437
niko Avatar asked Mar 12 '13 15:03

niko


People also ask

What is LocalApplicationData?

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

Where is AppData stored?

You can either access it manually or by using the "AppData" variable name. You can view the AppData folder manually by going into your Users folder, which is there in the C drive. In my case, the path is C:\Users\ADMIN . Now you should be able to see the AppData folder in your User folder.

What is environment SpecialFolder CommonApplicationData?

Environment. SpecialFolder. ApplicationData is the most common one. This folder holds per-user, non-temporary application-specific data, other than user documents. A common example would be a settings or configuration file.

Where is CommonApplicationData?

where %CommonApplicationData% is the location of the application data folder shared by all users. The exact location depends on the operating system, however, under Windows 7 or later the common application data folder is usually C:\ProgramData.


1 Answers

Both ApplicationData and LocalApplicationData are only accessible to the currently logged-in user. The difference between these two is that ApplicationData is replicated and synchronized to other devices which the user is using in an enterprise environment. It would be used to store a user's preferences.

As Raymond suggested (see docs), you're going to want to use a different folder. CommonDocuments would be a good option for documents to be shared between all users. CommonMusic if you're storing music and so on...

If you're wanting to store application-specific files use:

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
like image 68
Matthew K Avatar answered Sep 28 '22 03:09

Matthew K