0

I'm using log4net in my wpf solution. It is writing to error.xml correctly.

I need to change the permissions on the file so that every user on a PC has permission to write to error.xml.

How do I do this?

binncheol
  • 1,393
  • 4
  • 22
  • 38

1 Answers1

0

A more complicated way would be to ensure your application is integrated with UAC so that it requests elevated privileges when starting and then it will run with Admin rights and it will be able to write to that file. But it's not a good practice i think.

Another way would be to write to the Application Data folder like it is explaned here: log4net writing to file. How to open up permissions


Alternative solution: The installer will request elevated rights, create the file and give write rights to "Everyone".

Community
  • 1
  • 1
dutzu
  • 3,883
  • 13
  • 19
  • Unfortunately I need to store the error.xml at C:/Program Data/ProgramName/logs Is there no way of modifying the permissions of the error.xml? – binncheol Jan 29 '13 at 16:06
  • 1
    You need administrative permissions to write there - http://stackoverflow.com/questions/2362946/write-in-programdata-folder-w7-and-vista-net But you can create the manifest that will trigger a request for elevated rights for your application, and that will guarantee that you have access. Otherwise another approach would be that the installer creates this file and gives rights to "Everyone" to it so that the application can write to it. – dutzu Jan 29 '13 at 17:07
  • I think I'll have to get the installer to create the file as this will probably be the easiest solution as we don't want it to run as an administrator. Thanks! – binncheol Jan 29 '13 at 17:21
  • @binncheol i added it to my answer please mark it if suits your problem – dutzu Jan 30 '13 at 07:37