I have recently moved to Windows 7. Now my .NET application fails writing log file to C:\
My TraceListener is throwing the exception.
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
What to do? I am running application from the studio and so I think it must inherit all my rights and I am the admin on my pc.
If you have UAC enabled you won’t be able to write files to
C:\, even if you’re admin, unless you start the program in elevated mode to activate the admin privileges.Files shouldn’t really be placed in the root of
C:, so the best is to create a subdirectory and give yourself access rights (to your account, not the administrators group). If you really want to have the file onC:\and not run it as elevated, you can use Windows Explorer to grant yourself (your account, not the administrators group) write access toC:\.