Imports System.IO
Module Example
Public Sub Main()
Dim files() As String = Directory.GetFiles(".")
Array.Sort(files)
Array.ForEach(files, Function(s) WriteOutput(s))
Dim sw As StreamWriter = New StreamWriter(".\Files.txt")
sw.AutoFlush = True
Console.SetOut(sw)
Array.ForEach(files, Function(s) WriteOutput(s))
End Sub
Private Function WriteOutput(s As String) As Boolean
Console.Out.WriteLine(s)
Return True
End Function
End Module