How do i write data to text file in VB.NET ?
i want to write data to text file in vb.net.
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 11, 2011, 1:38 AM EDT
vijay172 reputationPosted May 31, 2011, 2:08 AM EDT
http://vbdotnetaddict.blogspot.com/2011/03/how-to-create-log-filetxt-in-vbnet.html
Rohatash KumarRank #12 · 57.7K reputationPosted Jun 3, 2011, 3:14 AM EDT
The below code define how to write data in text file in vb.net
Module Module1
Sub Main()
Dim fileName As String = "C:\rohatash\McTextFile.txt"
Using reader As New System.IO.StreamReader(fileName)
While Not reader.ReadLine() Is Nothing
Console.WriteLine(reader.ReadLine())
End While
End Using
Try
Using writer As New System.IO.StreamWriter(fileName, True)
writer.WriteLine("New text")
writer.WriteLine("New text line goes here")
End Using
Catch ex As Exception
End Try
Console.ReadKey()
End Sub
End Module