I am currently trying to grant my Windows Application acccess to write errors into a Log.txt file that is located in a restricted Directory.
Is there any way to let's say impersonate an admin, write to the log file and return the Application to regular user permissions.
Important information:
-I have to use .NET Framework 4.6 -I cannot make the Directory public
I tried modifying security properties of the Log.txt file, but this didn't work + doesn't seems to be the best option.
Edit: I know I can make my application request admin credentials on start but it has to be available to all users.
Justification:
The thing is I was asked to develop a Windows App with different functionalities. I am a junior programmer so I mainly just folllow orders. My supervisor told me to generate a log in the Application's installation path (C:\Program Files (x86)\MyApplication) for which all users have read-only access. The problem is the Application can't read as it's permissions are the same of the user's which, if not an admin, cant edit any file in that directory...