Reputation: 13
I have a windows service program that saves files in the application data folder of the local system user.I also have a windows form that needs to read those files and runs on different user accounts but I don't know how to get the environment variable of another user, specifically the local system. If it is possible i would appreciate an example, thank you in advance.
Upvotes: 0
Views: 2695
Reputation: 127603
Just call Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
and make a subfolder within the folder it returns to store your files. That location is designed to be the non user specific data storage location.
The default location is C:\ProgramData
but you should use the function to get it instead of hardcoding the path. Also you can't save files in the root of that folder but you can make subfolders and save your files in that.
Upvotes: 1