我的聊天应用程序在添加联系人详细信息时会删除文本文件中的当前文本,我该如何解决?
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
答案 0 :(得分:1)
Dim objWriter As New System.IO.StreamWriter(fileName, True)