Progress when using the Internet Transfer Control to upload a file.

OTveit
OTveit used Ask the Experts™
on
I'm using the Internet Transfer Control to upload a file to a known address.
After  logging on to a FTP server I use the Execute method:

Inet1.Execute , "PUT source.txt dest.txt"

I also use the StillExecuting property to check if the transfer is complete, but is there another way to monitor the progress of the transfer and mayby get how many bytes has been transfered?

Examples will be appreciated!

:)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:

You can try "Inet1_StateChanged" event for monitoring the upload process.

But I don't  think Internet transfer control has feature to check size.

"InternetOpen","InternetConnect" and "FtpPutFile" API function will do your needs.

Make use of this article "http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=520"

Author

Commented:
I got no problem with transfering the file and detecting when the file has been transfered. What I want is a way to monitor (show in a progress bar) how much (in % or bytes) has been trnasfered at any given time.


Can't see that any of the above tips do anything else than I am already doing...

:)
Commented:
hi OTveit,

c, following code will help u
this code transfers a file in byte manner by using FTP API,

u can get API def in msdn.

by
anand
*************
Private Sub Command1_Click()
'&H40000000 == GENERIC_WRITE
Dim Data(99) As Byte ' array of 100 elements 0 to 99
Dim Written As Long
Dim Size As Long
Dim Sum As Long
Dim j As Long

Sum = 0
j = 0
' for ASCII files use FTP_TRANSFER_TYPE_ASCII
hFile = FtpOpenFile(hConnection, Text5.Text, &H40000000, dwType, 0)
If hFile = 0 Then
    ErrorOut Err.LastDllError, "FtpOpenFile"
    Exit Sub
End If
Open Text4.Text For Binary Access Read As #1
Size = LOF(1)
For j = 1 To Size \ 100
    Get #1, , Data
    If (InternetWriteFile(hFile, Data(0), 100, Written) = 0) Then
        ErrorOut Err.LastDllError, "InternetWriteFile"
        Exit Sub
    End If
    DoEvents
    Sum = Sum + 100
    Label7.Caption = Str(Sum)
Next j
Get #1, , Data
 If (InternetWriteFile(hFile, Data(0), Size Mod 100, Written) = 0) Then
        ErrorOut Err.LastDllError, "InternetWriteFile"
        Exit Sub
End If
Sum = Sum + (Size Mod 100)
Label7.Caption = Str(Sum)
Close #1
InternetCloseHandle (hFile)
End Sub
**********************************

Author

Commented:
I'll try it and award you the points if it works! (please be patient....)

:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial