-
Jul 21st, 2011, 04:31 AM
#1
Thread Starter
Addicted Member
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
-
Jul 21st, 2011, 04:57 AM
#2
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.
-
Jul 21st, 2011, 05:01 AM
#3
Thread Starter
Addicted Member
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?
-
Jul 21st, 2011, 06:02 AM
#4
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.
-
Jul 21st, 2011, 08:03 AM
#5
Thread Starter
Addicted Member
Re: Copy File/directory using Buffer?
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).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|