I wrote a small desktop application, and deployed it using ClickOnce. The application uses a Trace listener to write to a log file. Later, it displays the log file in a multiline text box. Everything was working fine until I discovered the application
didn't have sufficient permissions to write to the log file on a deployed machine.
So, I tried ApplicationDeployment.CurrentDeployment.DataDirectory, but that was weird. I couldn't run the application in Visual Studio, because it would say the application wasn't deployed. Eventually, I surrounded the code in preprocessor directives, to
include it only in release mode, but I never could get it to read and write to the log file properly.
So, then I tried Application.LocalUserAppDataPath. It seems to write to the log file, but so far, I've not been able to read the file back into the textbox.
One question I have is: Although I'm writing this log using Trace, it should still be written in Release mode, right?
var traceListener = new LogWriterTraceListener();
public class LogWriterTraceListener : TraceListener
private readonly FileStream _fileStream;
public LogWriterTraceListener() : this(new FileStream(Application.LocalUserAppDataPath + "\\TestSQL.log", FileMode.Create, FileAccess.Write, FileShare.Read))
View Complete Post