10

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?

Community
  • 1
  • 1
niko
  • 9,285
  • 27
  • 84
  • 131
  • 1
    When in doubt [read the documentation](http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx). CommonApplicationData. – Raymond Chen Mar 12 '13 at 15:51
  • 1
    @RaymondChen why isn't this an answer, seeing as it's the answer? – pixelbadger Mar 12 '13 at 15:59
  • 1
    Probably because it is not the answer, c:\programdata is not writable. The default install of Windows does not provide a folder that all users can write to. If this is important then you'll need to create one and give Everybody write access. You'll probably find out, later, that dealing with one user screwing up the data of another user and not having a backup can be quite a headache. Which is why file servers exist. – Hans Passant Mar 12 '13 at 17:29
  • I have substantially edited your question to improve its focus and hopefully make it more useful to future readers. If you are unhappy with my revisions, please let me know. – DavidRR Nov 12 '15 at 15:55

1 Answers1

8

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)
Matthew K
  • 973
  • 6
  • 21