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\lo g\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 ProcessEachMess age
Dim swLog As StreamWriter
swLog = New StreamWriter(sP ath & "\bestdesk\log\ RiskIn" &
Date.Now.ToStri ng("MMddyy") & ".txt", True)
swLog.Write(Now & "NEWTRADE sMessage = " & Message & vbCrLf)
swLog.Close()
swLog = Nothing
:
Since each message is its own thread, many time I get the error "The process
cannot access the file "c:\bestdesk\lo g\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 ProcessEachMess age
Dim swLog As StreamWriter
swLog = New StreamWriter(sP ath & "\bestdesk\log\ RiskIn" &
Date.Now.ToStri ng("MMddyy") & ".txt", True)
swLog.Write(Now & "NEWTRADE sMessage = " & Message & vbCrLf)
swLog.Close()
swLog = Nothing
:
Comment