Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Create the file stream for the source file
- Dim streamRead as New System.IO.FileStream([sourceFile], System.IO.FileMode.Open)
- 'Create the file stream for the destination file
- Dim streamWrite as New System.IO.FileStream([targetFile], System.IO.FileMode.Create)
- 'Determine the size in bytes of the source file (-1 as our position starts at 0)
- Dim lngLen as Long = streamRead.Length - 1
- Dim byteBuffer(1048576) as Byte 'our stream buffer
- Dim intBytesRead as Integer 'number of bytes read
- While streamRead.Position < lngLen 'keep streaming until EOF
- 'Read from the Source
- intBytesRead = (streamRead.Read(byteBuffer, 0, 1048576))
- 'Write to the Target
- streamWrite.Write(byteBuffer, 0, intBytesRead)
- 'Display the progress
- ProgressBar1.Value = CInt(streamRead.Position / lngLen * 100)
- Application.DoEvents() 'do it
- End While
- 'Clean up
- streamWrite.Flush()
- streamWrite.Close()
- streamRead.Close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement