I want to store some files and edit them for my software in common Application Data under Windows 7.
I do not know why Windows 7 doesn't allow my software to change files unless I run them as administrator.
Where can I store my files, so it won't require admin permission?
You should store your application data in a subfolder under Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
. Note that this folder is user-specific.
Non-Admin users do not have permission to write to the CommonApplicationData
folder, because that folder does not belong to specific users.
Note that you can also store your settings by using the Settings Class. To do so, add New Item to your project, pick "Settings File". This is appropriate for basic settings like strings and numbers.
Some folders are restricted starting in windows 7, these folders should not be touched unless you are installing, uninstalling, or patching. Please see my answer that you accepted from earlier today it is the exact same case.
If you have multiple aplications that need to edit the same files they should be stored in
Environment.GetFolderPath( Environment.SpecialFolder.CommonApplicationData)
System.Environment.SpecialFolder.CommonProgramFiles
(the folder I think you are trying to write to) is read only unless you are elevated.
read this article from the MSDN it explains where you should be saving data and how do use the various folders correctly. My solution is the first one on his list, to summarize:
You need to create a folder while you are installing the program in the CommonApplicationData folder then set permissions on that new folder so it will have write access from the users group.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With