Network Transfer (FTP) problem

Source: Internet
Author: User
Network | problems
Dim Buffer as String
Dim buffersize as Integer
Dim Filelength as Long, superbuffer as Long
Dim PercentDone as Long, B as Integer

Open Xfilename for Binary Access read as #i ' Open the file to Read
Filelength = LOF (i)

If LOF (i) <> 0 Then
Do, not EOF (i): DoEvents
If Filelength-loc (i) < buffersize Then
Let buffersize = Filelength-loc (i)
If buffersize = 0 Then GoTo Done
End If

Buffer = Space (buffersize)
Get #i,, Buffer

Superbuffer = Superbuffer + Len (Buffer)
Debug.Print "Buffersize=" & buffersize & "Superbuffer=" & Superbuffer & "Loc (" & I & ") =" & Loc (i)
Loop
End If
Close #i


Immediate Window Print results:
buffersize=2048 superbuffer=2048 Loc (1) =2188
buffersize=2048 superbuffer=4096 Loc (1) =5146
.......
.......
buffersize=2048 superbuffer=22571008 Loc (1) =32422628
buffersize=56 superbuffer=22571064 Loc (1) =32422690

Problem:
The file size is actually 30.9M, but the end can only be transmitted to 28.1M, the problem is in the location of the file read loc (1) and the actual transmission of the file size of the different steps,
If Filelength-loc (i) < buffersize Then
Let buffersize = Filelength-loc (i)
If buffersize = 0 Then GoTo End Process
End If
This process is judged as early as the end of the read.

Please all heroes to guide, if you can solve my gratitude, there must be a high score reward!
can be resolved to send my mailbox: caopengzhao@sohu.com, can also be directly written here, thank you!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.