Write Text to a File and read back
Imports System
Imports System.IO
Imports System.Text
Class Program
Public Shared Sub Main(ByVal args As String())
Dim mydocpath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
Dim txtList As String() = Directory.GetFiles(mydocpath, "*.txt")
Dim sb As New StringBuilder()
For Each txtName As String In txtList
Using sr As New StreamReader(txtName)
sb.AppendLine(txtName.ToString())
sb.AppendLine("= = = = = =")
sb.Append(sr.ReadToEnd())
sb.AppendLine()
sb.AppendLine()
End Using
Next
Using outfile As New StreamWriter(mydocpath & "\AllTxtFiles.txt")
outfile.Write(sb.ToString())
End Using
End Sub
End Class
Related examples in the same category