' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.IO

Module Main
    Sub Copy(fnm1 As String, fnm2 As String)
        Dim cr As String = Convert.ToChar(13)
        Dim size As Integer = (new FileInfo(fnm1)).Length
        Dim f1 As Stream = New FileStream(fnm1, FileMode.Open, FileAccess.Read)
        Dim f2 As Stream = new FileStream(fnm2, FileMode.Create, FileAccess.Write)
        Dim c As Integer
        Dim n As Integer = 0
        Dim more as boolean = True
        While (more)
            c = f1.ReadByte
            If c >= 0 then
                f2.WriteByte(CType(c, Byte))
                n = n + 1
                If (n Mod 100000) = 0 Then
                    Console.Write(cr & n & " af " & size)
                End If
            Else
                more = False
            End If
        End While
        f1.Close
        f2.Close
        Console.WriteLine(cr & n & " af " & size)
    End Sub
    Sub Main()
        Copy("C:\z1.dat", "C:\z2.dat")
    End Sub
End Module
