Estoy usando la función InternetWriteFile() para realizar actualizaciones a un FTP y cuando el archivo tiene un tamaño mayor a 9kb la transaccion se corta.
Este es ejemplo del código que estoy usando :
- Code: Select all Expand view RUN
FUNCTION FtpWriteFile(cFtpSite,cFtpUser,cFtpPassword,cFtpLocal,cFtpRemote,oFtpMeter,nMeterStart,nMeterEnd)
LOCAL hInternet, hConnect,lReturn, i
local cBuffer:=space(1024)
local nBufSize:=1024
local handle
local nSize
local nProgress
local nWritten:=0
local lValue
local nRange
local hFile
local nBytes
nSize:=fsize(cFTPlocal)
if oFTPMeter<>NIL
nRange:=nMeterEnd-nMeterStart
endif
ftplog("")
ftplog("Session FTPWRITEFILE - Site: "+cFtpRemote+" Local file:"+cFtpLocal+" Remote file: "+cFtpRemote)
ftplog("Loading Wininet.dll")
hLib := LoadLibrary( "\Windows\System32\wininet.dll" )
* hLib := Control("wininet.dll",oDlg)
ftplog("Done. Handle:"+str(hLib,10))
ftplog("Calling InetOpen")
hInternet := INETOPEN( "Anystring", 0, 0, 0, 0 )
ftplog("Done. Handle:"+str(hInternet,10))
ftplog("Calling hConnect")
hConnect = INETCONNECT( hInternet, cFtpSite, 21, cFtpUser, cFtpPassword,INTERNET_SERVICE_FTP, 0, 0 )
ftplog("Done. Handle:"+str(hConnect,10))
ftplog("Calling FtpOpenFile")
hFile := FtpOpenFile( hConnect, cFtpRemote, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0 )
ftplog("Done. Handle:"+str(hFile,10))
nProgress:=0
handle:=fopen(cFtpLocal)
while ( nBytes := FRead( handle, @cBuffer, nBufSize ) ) > 0
lReturn:=InternetWriteFile(hFile, cBuffer, nBytes, @nWritten )
if lReturn=.f.
ftplog("Write error."+str(hFile,10))
endif
nProgress += nWritten
ftplog("Wrote "+alltrim(str(nProgress,10))+" of "+alltrim(str(nSize,10)))
if oFTPMeter<>NIL
oFTPMeter:Set(nMeterStart+(nProgress*nRange)/nSize)
endif
end
FClose( handle )
lValue:=INETCLOSE( hFile )
if lValue
ftplog("Closing FtpOpenFile. Ok.")
else
ftplog("Closing FtpOpenFile. Error.")
endif
lValue:=INETCLOSE( hConnect )
if lValue
ftplog("Closing HCONNECT. Ok.")
else
ftplog("Closing HCONNECT. Error.")
endif
lValue:=INETCLOSE( hInternet )
if lValue
ftplog("Closing HINTERNET. Ok.")
else
ftplog("Closing HINTERNET. Error.")
endif
lValue:= FreeLibrary( hLib )
if lValue<>0
ftplog("Closing WININET. Ok.")
else
ftplog("Closing WININET. Error.")
endif
RETURN lReturn