Hi,
IF i want to write a line at the same time in append mode how m i suppose to
do.
here is my code.... and this function may be called more then once at the
same time....
and it works fine... but the only thing is that.. sometime i get the error :
The process cannot access the file "c:\nie\LOGS\1062005.txt" because it is
being used by another process.
and i guess this is true as this function is getting called more then once
at the sametime on the same thread and its trying to over lap.
below is the function
Public Function WriteServiceLog(ByVal EventCode As String, ByVal Details As
String)
Dim Path As String = AppDomain.CurrentDomain.BaseDirectory & "\LOGS\"
Dim FileName As String = Replace(FormatDateTime(Date.Now,
DateFormat.ShortDate), "/", "") & ".txt"
If Not System.IO.Directory.Exists(Path) Then
System.IO.Directory.CreateDirectory(Path)
End If
'Dim FStream As New System.IO.FileStream(Path & FileName,
IO.FileMode.Append, IO.FileAccess.ReadWrite)
Dim StreamWriter As New System.IO.StreamWriter(Path & FileName, True)
StreamWriter.WriteLine(EventCode & " " & FormatDateTime(Date.Now,
DateFormat.LongTime) & " " & Details)
StreamWriter.Close()
End Function
Any help?
Cheers
C