How to create and add data to a text file in VB.NET
Posted on 2003-10-27
I have three text boxes and an Add button. I want basically to create a Downloader.txt file in the directory c:\vb.net\files\Downloader.txt
I'm trying to use the following code but unable to create the above text file and add the data from three textboxes to the Downloader.txt file.
Primarily I want to check the Downloader.txt file exists in the above directory, if not I want to create it or if it exists I want to append the data to the file.
Here is the code:
Dim datdownloader As New StreamWriter("downloader.txt", True)
Dim strrecord As String
If IsNumeric(txtname.Text) Then
MessageBox.Show("Enter A string Value ", "Invalid data Entry", _
strrecord = (txtname.Text & "|" & txtdownloads.Text & "|" & txtaddress.Text)
'I WANT TO ADD THE ABOVE strrecord to the Downloader.txt file if it exits, if not i want to create and append the strrecord to that file.
I appreciate your response.