CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    13

    Progress bar with a transferring file

    I am using the Inet control to transfer files between the local machine and an FTP site. I would like to have a progress bar showing the status of the file being sent/received. I know how to get the size of the file for the max value on the progres bar but is there a way to determine how much of the file has been sent/received already? Any links/tips/suggestions would be helpful, especially if it requires any kind of API call. Thanks

    Ryan


  2. #2
    Join Date
    Sep 2001
    Location
    Little Rock, Arkansas
    Posts
    40

    Re: Progress bar with a transferring file

    I cut-and-pasted the example code out of the help file, added a couple of lines (look for the debug.print statement) and was able to come up with something close to what you need:


    option Explicit

    private Sub Form_Load()
    INet1.Document = "PICS.FINANCE.JPG"
    INet1.Execute , "get"
    End Sub

    private Sub Inet1_StateChanged(byval state as Integer)

    Dim vtData as Variant
    Dim strFileName as string
    Dim lngLength as Long

    Select Case state
    ' ... Other cases not shown.

    Case icResponseCompleted ' 12
    Dim bDone as Boolean: bDone = false
    Dim tempArray() as Byte

    strFileName = "E:\TestJunk.jpg"
    Open strFileName for binary Access Write as #1

    ' get first chunk.
    vtData = INet1.GetChunk(1024, icByteArray)
    DoEvents

    If len(vtData) = 0 then
    bDone = true
    End If

    Do While Not bDone
    tempArray = vtData
    Put #1, , tempArray

    ' get next chunk.
    vtData = INet1.GetChunk(1024, icByteArray)
    DoEvents

    lngLength = lngLength + 1024
    Debug.print "Progress: " & lngLength

    If len(vtData) = 0 then
    bDone = true
    End If
    Loop

    Close #1
    End Select
    End Sub





  3. #3
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: Progress bar with a transferring file

    Maybe you can calculate the received part so far and just divide the received file so far by the total size.. And then ask progress bar to show that percentage...

    Nic

    Nicolas Bohemier

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured