Copy File/directory using Buffer?
Can anybody please explain to me what this code will do to the copy?
vb Code:
Using source As New IO.FileStream("source path here", IO.FileMode.Open)
Using target As New IO.FileStream("destination path here", IO.FileMode.Create)
Const BUFFER_SIZE As Integer = 1024
Dim buffer(BUFFER_SIZE - 1) As Byte
Dim bytesRead As Integer = source.Read(buffer, 0, BUFFER_SIZE)
While bytesRead > 0
target.Write(buffer, 0, bytesRead)
bytesRead = source.Read(buffer, 0, BUFFER_SIZE)
End While
target.Close()
End Using
source.Close()
End Using
Re: Copy File/directory using Buffer?
Without trying it, it looks like it copies data in chunks of 1024 bytes from one file into another. I could not believe that this is faster than a standard copy, so unsure of its benefit.
Re: Copy File/directory using Buffer?
Is there any way to do a copy, in vb.net, of files and folders FASTER than windows explorer?
Re: Copy File/directory using Buffer?
I would hope not, or windows did not do a very good job! Seroiusly, I have never tested it, there could be faster methods which skip the feedback that explorer gives you, surely at a lower level then .Net.
There are ways to copy files for backup/mirror reasons which use techniques of only copying what is needed (ie robocopy). Depends what you are trying to achive.
Re: Copy File/directory using Buffer?
Quote:
Originally Posted by
Grimfort
Depends what you are trying to achive.
I want a quick backup of the system, but I also want the user to be in total control ie. being able to pause the backup/copy at any moment and continue at a later stage (The backup kills the system resources while running).