添加联系人详细信息时,我的聊天应用程序会删除文本文件中的当前文本,如何解决此问题?

时间:2015-03-08 12:55:47

标签: vb.net visual-studio-2012

我的聊天应用程序在添加联系人详细信息时会删除文本文件中的当前文本,我该如何解决?

Private Sub btnAddContact_Click(sender As Object, e As EventArgs) Handles btnAddContact.Click

    If lblFileName.Text = "No file selected!" Then

        MsgBox("No file selected!", MsgBoxStyle.Exclamation)

    Else

        If System.IO.File.Exists(fileName) = True Then

            Dim objWriter As New System.IO.StreamWriter(fileName)

            objWriter.WriteLine(tbUsername.Text & "," & tbIP.Text & "," & tbFirstName.Text)
            objWriter.Close()
            MsgBox("Added Contact!")

        Else

            MsgBox("File Does Not Exist")

        End If

    End If
End Sub

1 个答案:

答案 0 :(得分:1)

Dim objWriter As New System.IO.StreamWriter(fileName, True)