|
-
Oct 29th, 2003, 09:43 PM
#1
Thread Starter
Lively Member
TextWriter locking files
I have an ASP.Net project where I have taken all of the error logging and created a new VB.Net logging class.
In the ASP.net project I have a reference to the new VB.Net logging class.
I have a try catch block, in the catch I create a logging object and call the logging from there. This all works great.
The problem I am having is that after the first log is written, the log file is locked. The code for logging is the exact same as before (and it worked like a charm when it was in the same ASP.Net project). Now that it is a Class that is reference to, it some how keeps a lock on the file. Any ideas?
Sample code from Logging class where it opens the file and writes the text:
Dim FileWriter As TextWriter = File.AppendText(oLoggingProperties.LoggingFileName & ".txt")
FileWriter.WriteLine(sLevel & " Error Log " & Date.Now & " From Class - " & sClass & " Method - " & sMethod)
FileWriter.WriteLine(oException.Message)
FileWriter.WriteLine(oException.Source)
FileWriter.WriteLine(oException.StackTrace)
FileWriter.WriteLine(oException.TargetSite)
FileWriter.WriteLine("")
FileWriter.Close()
Sample code from the WebForm1.aspx.vb code behind file:
Try
... some code .....
Catch oException As Exception
Dim lLogging As Logging.Logging = New Logging.Logging()
lLogging.Log(oException, "Login", "btnLogin_Click", "Fatel")
Err.Clear()
End Try
Any ideas of how to make sure the file is closed?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|