Search code examples
c#wpfspecial-folders

Access Computer's Default AppData Folder


I am currently trying to use the following to access a computer's local AppData folder:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

This returns something along the lines of C:\\Users\\[USERNAME]\\AppData\\Roaming. What I want is to get the default AppData folder, as opposed to any specific user's folder.

I can hard code this C:\Users\Default\AppData\Local, but I'd feel more comfortable if there was a function that provided what I'm looking for.

Is there such a function, and if so, what is it?


Solution

  • I believe SpecialFolder.CommonApplicationData will get what you need.

    From the MSDN documentation:

    The directory that serves as a common repository for application-specific data that is used by all users.