vb.net Appending a text file to create log..
Here is the procedure to Appending a text file to create log in vb.net
Private Function makeLog() As Boolean
Dim path As String = "log.txt"
Dim sw As StreamWriter
' This text is added only once to the file.
If File.Exists(path) = False Then
' Create a file to write to.
sw = File.CreateText(path)
sw.Flush()
sw.Close()
End If
' This text is always added, making the file longer over time
' if it is not deleted.
sw = File.AppendText(path)
sw.WriteLine("<<<<<<<<<<<<<<<")
sw.WriteLine(lblStatus.Text)
sw.WriteLine(">>>>>>>>>>>>>>>")
sw.Flush()
sw.Close()
'' Open the file to read from.
'Dim sr As StreamReader = File.OpenText(path)
'Dim s As String
'Do While sr.Peek() >= 0
' s = sr.ReadLine()
' Console.WriteLine(s)
'Loop
'sr.Close()
End Function
Comments