Error writing to a file

F

fniles

For each message that my application receives I write it to a log file.
Since each message is its own thread, many time I get the error "The process
cannot access the file "c:\bestdesk\log\RiskIn051707.txt" because it is
being used by another process." Is there a way to get around this error ? I
can do the same thing in VB6 with no problem. Thank you.

This is how I write to the file:
Sub ProcessEachMessage
Dim swLog As StreamWriter

swLog = New StreamWriter(sPath & "\bestdesk\log\RiskIn" &
Date.Now.ToString("MMddyy") & ".txt", True)
swLog.Write(Now & "NEWTRADE sMessage = " & Message & vbCrLf)
swLog.Close()
swLog = Nothing
:
 

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