This is the code I use in the VB.net, but it never give me problem. It runs concurrent with Java Applet, the problem is the Delphi application that give the error. I have no the Delphi code but I had a look on it and it use low level access to the file ...
Private Function cercabanconote() As BooleanDim swok As Boolean = True
valore = 0
Try
If File.Exists(BILLS_FILENAME) Then
Try
Dim sr As StreamReader = New StreamReader(BILLS_FILENAME)
valore = sr.ReadLine
sr.Close()
Catch ex As Exception
Setlog("BILLS_FILENAME->" + ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "BILLS_FILENAME")
valore = 0
swok = False
End Try
If valore > 0 Then
Try
Dim sw As StreamWriter = New StreamWriter(BILLS_FILENAME)
sw.Write("0")
sw.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "BILLS_FILENAME")
Setlog("billsfilename->" + ex.Message)
valore = 0
swok = False
End Try
End If
End If
Catch ex As Exception
Setlog("File.Exists->" + ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "File.Exists")
End Try
If valore > 0 Then
Setlog("caricati ->" + valore.ToString)
End If
Return swok
End Function