Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to automate getting a file from the web
Message
From
16/09/2005 11:14:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
16/09/2005 10:58:18
General information
Forum:
Visual FoxPro
Category:
Internet applications
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01050252
Message ID:
01050282
Views:
11
>Tore,
>
>Great code! In looking at your long example, is there a way to retrieve a file's length before reading it in blocks? If one knew the length of the file being retrieved, they could add a progress meter to the long version of your code.
>
>Thank you,
>Malcolm

Something like this:
	.ProgBar.Value = 0
	lpdwFileSizeHigh = 0
	lnSize = FtpGetFileSize(hFile, @lpdwFileSizeHigh)
	lnSize = lnSize + lpdwFileSizeHigh * (0xFFFFFFFF+1)

	.ProgBar.Max = lnSize
	.FTPResponse('Transferred '+trans(0)+' of '+trans(lnSize)+' bytes.')

	hOut = fcreate(.txtLocalFile.Value)
	lnBytesWritten = 0
	Do while lnBytesWritten < lnSize
		lpdwNumberOfBytesRead = 0
		lcRead = space(100)
		If InternetReadFile(hFile, @lcRead, 100, @lpdwNumberOfBytesRead) = 0
			.FTPResponse("InternetReadFile error.")
			Return
		Endif
		lnBytesWritten = lnBytesWritten + fwrite(hOut,lcRead,lpdwNumberOfBytesRead)
		.ProgBar.Value = min(.ProgBar.Value+lpdwNumberOfBytesRead,.ProgBar.Max)
		.FTPResponse('Transferred '+trans(lnBytesWritten)+' of '+trans(lnSize)+' bytes.')
	Enddo
	=fclose(hOut)
	InternetCloseHandle(hFile)
	.FTPResponse('Transfer completed.')
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform