Am getting access denied to a log file for开发者_Python百科 normal user in windows 7 system, along with contact administrator message. but in xp machine its working fine for both normal and admin users.
Should be windows 7. Even i encountered the same problem.
I have a console application which launches when the application is built in my local machine and by double clicking the exe file in bin folder. The log file used by the application is accessible and gets updated properly.
But when i create an MSI for the application and when i install it and launch the exe, i am getting access denied for a log file,
You may be aware of the modifications to Windows Vista and Windows 7 regarding the program files directory. Basically if any user can write to this directory, they could modify an executable which a user could then execute which is a massive security hole.
As such the new versions of windows will not allow you to write into the program files directory unless you have administrator permissions, by design.
There are recommended folders for you to use depending on what you need to do and how many users the file needs to be shared with. Have a look at the Environment.GetFolderPath()
which has cross platform API's to retrieve the safe location to write in the user context.
The other alternative is to write an MSI which then creates a special ACL on the file which will allow the user to edit it, but why make your application brittle if all you are after is a log file.
精彩评论