Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FTP con barra de Progreso (FTP with progressbar)
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00739676
Message ID:
00739732
Views:
15
Hi,
use these two function from wininet.dll

DECLARE INTEGER InternetWriteFile IN wininet.dll;
INTEGER hFile, STRING @ sBuffer, INTEGER lNumBytesToWrite,;
INTEGER @ dwNumberOfBytesWritten

DECLARE INTEGER InternetReadFile IN wininet;
INTEGER hFile,STRING @ sBuffer,;
INTEGER lNumBytesToRead, INTEGER @ dwNumberOfBytesRead

Here's a little bit fo code how I read an ftpfile from the server. The code is a mixture from parts of ftp.prg (In the Download-Section) and information from http://www.news2news.com/vfp/index.php, a very good resource to find almost anything about using dlls with VFP.


procedure ireadfile_message
parameters lcremotefile, lclocalfile, oObject
* The object which displays the info is the last parameter
local hTarget
local hsource
local lnbyteswritten
local lnChunksize
hTarget = FCREATE (lclocalfile)
If (hTarget = -1)
Return 0
Endif
if this.OpenFtpConnection()
hSource = FtpOpenFile(this.nConnect_Handle, lcRemotefile, GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, 0)
If hSource = 0
= FCLOSE (hTarget)
Return 0
Endif
lnBytesRead = 0
lnChunkSize = 256 && Size of block being read
Do WHILE .T.
lcBuffer = REPLI (Chr(0), lnChunkSize)
lnLength = Len (lcBuffer)
If InternetReadFile (hSource, @lcBuffer, lnLength, @lnLength) = 1
= FWRITE (hTarget, lcBuffer, lnLength)
lnBytesRead = lnBytesRead + lnLength
oObject.caption = alltrim(str(lnBytesread)) && I use a label for
If lnLength < lnChunkSize && displaying progress
Exit
Endif
Else
Exit
Endif
Enddo
= InternetCloseHandle (hSource)
= FCLOSE (hTarget)
Return lnBytesRead
Else
Return 0
Endif

Hope this helps

Thomas
Previous
Reply
Map
View

Click here to load this message in the networking platform