保存文本文件

时间:2016-11-15 14:04:52

标签: vb.net

我有一个程序可以保存我们车间的简单程序中的数据。我遇到的问题是,由于与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

0 个答案:

没有答案