我有一个程序可以保存我们车间的简单程序中的数据。我遇到的问题是,由于与2个不同的人同时写入文件的冲突,我收到重复的条目
Do While done = 0 And attempt < 1
done = 1
Try
Using theWriter As New System.IO.StreamWriter(ReportText, True)
For Each currentrow As DataGridViewRow In Me.ReportGrid.Rows
' The Cells are the Columns
For Each currentcolumn As DataGridViewCell In currentrow.Cells
theWriter.Write(currentcolumn.Value & vbTab)
Next
theWriter.WriteLine()
Me.ReportGrid.Rows.Remove(currentrow)'the new line added
Next
theWriter.Close()
End Using
Catch When Err.Number = 75
wait(2000)
done = 0
attempt = attempt + 1
Catch When Err.Number <> 53
Notify()
End Try
Loop