File Directory VB.Net

Imports System
Imports System.IO
Public Class BinaryRW
    Shared Sub Main()
        Dim i As Integer
        Const upperBound As Integer = 1000
        Dim dataArray(upperBound) As Double
        For i = 0 To upperBound
            dataArray(i) = 100.1 * i
        Next i
        Dim binWriter As New BinaryWriter(New MemoryStream())
        Try
            For i = 0 To upperBound
                binWriter.Write(dataArray(i))
            Next i
            Dim binReader As New BinaryReader(binWriter.BaseStream)
            binReader.BaseStream.Position = 0
            Try
                For i = 0 To upperBound
                    If binReader.ReadDouble() <> dataArray(i) Then
                        Console.WriteLine("Error writing data.")
                        Exit For
                    End If
                Next i
            Catch ex As EndOfStreamException
                Console.WriteLine("Error writing data: {0}.",ex.GetType().Name)
            End Try
        Finally
            binWriter.Close()
        End Try
    End Sub
End Class