首页 > 开发 > 综合 > 正文

网络传输(FTP)问题

2024-07-21 02:16:03
字体:
来源:转载
供稿:网友

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 while 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


//立即窗口打印结果:
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

//问题:
文件大小实际是30.9m,但最后只能传输到28.1m就结束了,问题出在文件读取的位置loc(1)和实际传输的文件大小不同步,在
if filelength - loc(i) < buffersize then
   let buffersize = filelength - loc(i)
   if buffersize = 0 then goto 结束过程
end if
这个过程判断时及早结束读取。

请各位大侠指点,如能解决本人不胜感激,必有高分酬谢!
可将解决方法发送本人邮箱:[email protected] ,也可直接写到这里,谢谢各位!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表