StreamWriter Implements a TextWriter for writing characters to a stream in a particular encoding.
Imports System.IO
Class Program
Shared Sub Main()
Dim cDirs As DirectoryInfo() = New DirectoryInfo("c:\").GetDirectories()
Using sw As StreamWriter = New StreamWriter("data.txt")
For Each Dir As DirectoryInfo In cDirs
sw.WriteLine(Dir.Name)
Next
End Using
Dim line As String = ""
Using sr As StreamReader = New StreamReader("data.txt")
Do
line = sr.ReadLine()
Console.WriteLine(line)
Loop Until line Is Nothing
End Using
End Sub
End Class