Where can I write a debug.txt file ?

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'?
 
J

Jeff Gaines

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
 
A

Arne Vajhøj

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top