作者shoaming (修明)
看板Visual_Basic
标题[VBA ] 想请问一下runtime error
时间Wed Mar 21 12:59:44 2007
现在的问题是处理一个FTP上传档案的问题
由於资料有4G这麽大
当我在资料上传到一半的时候发生runtime error'63':资料录个数不正确
请问一下这是一个什麽样的问题?
下面有source code
发生错误的程式码在 Get #ff, , sBuffer
Public Function PutFile(ByVal LocalFile As String, ByVal Destination As String) As Boolean
PutFile = False
If Not (bActiveSession) Then Exit Function
If Not (FileReal(LocalFile)) Then Exit Function
Dim sBuffer As String * 1024
Dim FileData As String
Dim SentBytes As Double
Dim nRet As Long
Dim spRate As Integer
Dim nTotFileLen As Long
Dim nFileLen As Long
Dim hFile As Long
Dim t As Long
Dim ff As Integer
ff = FreeFile
DelFile = Destination
Open LocalFile For Binary As #ff
If (ff = 0) Then Exit Function
nTotFileLen = LOF(ff)
SentBytes = 0
nFileLen = 0
spRate = 0
hFile = FtpOpenFile(hConn, Destination, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0)
If hFile = 0 Then
Exit Function
End If
Do
Get #ff, , sBuffer
Label1.Caption = "档案上传中"
Label1.Refresh
If nFileLen < nTotFileLen - sReadBuffer Then
If InternetWriteFile(hFile, sBuffer, sReadBuffer, nRet) = 0 Then
Call RemoveFile(DelFile)
Exit Function
End If
SentBytes = SentBytes + sReadBuffer
nFileLen = nFileLen + sReadBuffer
Else
If InternetWriteFile(hFile, sBuffer, nTotFileLen - nFileLen, nRet) = 0 Then
Call RemoveFile(DelFile)
Exit Function
End If
SentBytes = SentBytes + (nTotFileLen - nFileLen)
nFileLen = nTotFileLen
End If
Loop Until nFileLen >= nTotFileLen
Close
InternetCloseHandle hFile
PutFile = True
Label1.Caption = "档案上传完毕"
Label1.Refresh
Call ListRemoteFile(RemoteDir)
End Function
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.120.155.49