Imports System.IO
Imports System.Text
Public Class Tester
Public Shared Sub Main
Dim mySourceFileStream As FileStream
Dim myDestFileStream As FileStream
Dim bteRead() As Byte
Dim intByte As Integer
Dim bteMessage(128) As Byte
Dim strCopyMessage As String = ""
Try
myDestFileStream = New FileStream("dest.txt", FileMode.OpenOrCreate, FileAccess.Write)
bteMessage = Encoding.ASCII.GetBytes(strCopyMessage)
myDestFileStream.Write(bteMessage, 0, bteMessage.Length)
mySourceFileStream = New FileStream("source.txt", FileMode.OpenOrCreate, FileAccess.Read)
intByte = mySourceFileStream.Length
ReDim bteRead(intByte)
mySourceFileStream.Read(bteRead, 0, intByte)
myDestFileStream.Write(bteRead, 0, intByte)
myDestFileStream.Close()
mySourceFileStream.Close()
Catch ex As IOException
Console.WriteLine(ex.Message)
End Try
End Sub
End Class
|