Where can I write a debug.txt file ?

  • Thread starter Thread starter Cralis
  • Start date Start date
C

Cralis

I have an application, within which a user can set debug logging on.
This enables the winforms application to write log lines to a txt
file. I was writing it in the same folder as where the application
runs from (c:\Program Files (x86)....) This seems a bad plan, as they
may not have permission to create and write to a file here.

Where could I write this file instead? Or is there a way to give the
application access to the folder without the user having to do the
'Run as Administrator'?
 
I have an application, within which a user can set debug logging on.
This enables the winforms application to write log lines to a txt
file. I was writing it in the same folder as where the application
runs from (c:\Program Files (x86)....) This seems a bad plan, as they
may not have permission to create and write to a file here.

Where could I write this file instead? Or is there a way to give the
application access to the folder without the user having to do the
'Run as Administrator'?

Look at Environment.SpecialFolder:

http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
 
I have an application, within which a user can set debug logging on.
This enables the winforms application to write log lines to a txt
file. I was writing it in the same folder as where the application
runs from (c:\Program Files (x86)....) This seems a bad plan, as they
may not have permission to create and write to a file here.

Where could I write this file instead? Or is there a way to give the
application access to the folder without the user having to do the
'Run as Administrator'?

Use a logging framework like log4net so that it is configurable
where the log file is placed.

Arne
 
Back
Top