StreamWriter Class 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("CDriveDirs.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("CDriveDirs.txt")
Do
line = sr.ReadLine()
Console.WriteLine(line)
Loop Until line Is Nothing
End Using
End Sub
End Class