Problem Logging Due to Security on Files


  • My program has a pretty extensive logging feature but the way I implemented it, the logging is stored in log files in the Program Files directory.  But, I can not write to the log files unless the user runs the program as an administrator.


    Is there a way to be granted access to a directory in the Program Files folder?


    Another option I thought of was placing in the log files in the same location that the .config file is located.  But, I'm not sure how to determine where that file is stored as it is usually stored under some ridiculous folder name like




    or something.


    Is there a way to determine where the .config file is being stored?  Is that a ligit solution to store logs there?

    Sunday, May 04, 2008 3:19 AM


  • The Program Files directory is purposely read-only to non admins for a reason.  You could simply change permissions when your application is installed (when your code is run as an administrator) but that would likely allow any program to access the Program Files directory, a security violation!.  I would suggest you write user-specific data to the user's directory, as recommended.  See SpecialFolder.LocalApplicationData.
    Sunday, May 04, 2008 2:11 PM