I’m making a form with a checkbox where if checked a target file is appended with text-A and if Unchecked the file is appended with text-B
How can I do this?
what i have sofar:
Private Sub CheckBox1_Checked(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Checked
Dim FILE_NAME As String = "C:\ANSWERSLIST.txt"
'Adding items for AutoCAD 2006...
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
objWriter.WriteLine("YES")
开发者_高级运维 objWriter.Close()
End If
End Sub
You could use the AppendAllText method:
If MyCheckBox.IsChecked Then
File.AppendAllText("foo.txt", "text-A")
Else
File.AppendAllText("foo.txt", "text-B")
End If
精彩评论