Link to home
Start Free TrialLog in
Avatar of thaburner
thaburnerFlag for United States of America

asked on

Problem downloading file with INET

Basically what im trying to do is I have an software updater, in the GetFileDetails it reads all the files that need updates. Well the DownloadFile function is not downloading my files for some reason but If i put the same DownloadFile function in a command button works fine... Any Idea's I posted the code that i though might be related to any problems....


Public Function LoadUpdatesList()
Dim iCount As Variant
Dim sFiles As String
Dim i As Integer

sFiles = ReadIni("Update Settings", "Files")
iCount = Split(sFiles, "%")
iUDSFileCount = 0
For i = 1 To UBound(iCount)
    Dim X As String
    X = iCount(i)
    GetFileDetails i
Next i

End Function

Public Function GetFileDetails(s As Integer)
With FileSettings(s)
    If .NeedsUpdate = True Then
        frmUpdateScreen.lblLatestVersion.Caption = .FileVersion
        frmUpdateScreen.lblLatVerRel.Caption = .ReleaseDate
        frmUpdateScreen.lblFileSize.Caption = .FileSize
        frmUpdateScreen.lblFilename.Caption = .FileName
        DownloadFile FileSettings(s).DownloadPath1, App.Path & "\" & FileSettings(s).FileName, frmUpdateScreen.Inet1
    End If
End With
End Function

Public Sub DownloadFile(strSrcHTTPFile As String, strDestSaveFile As String, objbInet As Inet)
    m_DownloadingFile = False
   
    m_DownloadingFileSize = GetHTTPFileSize(strSrcHTTPFile, objbInet)
    If m_DownloadingFileSize <> -1 Then
        m_LocalSaveFile = strDestSaveFile
        m_DownloadingFile = True
        objbInet.Execute strSrcHTTPFile, "GET " & Chr(34) & strDestSaveFile & Chr(34)
    Else
        MsgBox "Error getting file information"
    End If
End Sub



Public Function GetHTTPFileSize(strHTTPFile As String, objInet As Inet) As Long
'On Error GoTo ErrorHandler
'On Error Resume Next
    Dim GetValue As String
    Dim GetSize  As Long
    Dim MBSize As Double
   
    m_GettingFileSize = True
    Do Until objInet.StillExecuting = False
        objInet.Cancel
        DoEvents
    Loop
    objInet.Execute strHTTPFile, "HEAD " & Chr(34) & strHTTPFile & Chr(34)

    Do Until objInet.StillExecuting = False
        DoEvents
    Loop

    GetValue = objInet.GetHeader("Content-length")
   
    Do Until objInet.StillExecuting = False
        DoEvents
    Loop
   
    If IsNumeric(GetValue) = True Then
        GetSize = CLng(GetValue)
    Else
        GetSize = -1
    End If

    If GetSize <= 0 Then GetSize = -1

    m_GettingFileSize = False
    GetHTTPFileSize = GetSize

Exit Function

ErrorHandler:
    m_GettingFileSize = False
    GetHTTPFileSize = -1
End Function
Avatar of Mark_FreeSoftware
Mark_FreeSoftware
Flag of Netherlands image


how do you call this code?
Avatar of thaburner

ASKER

on the main window there is a start button which calls LoadUpdatesList and thats it in the button
ASKER CERTIFIED SOLUTION
Avatar of Mark_FreeSoftware
Mark_FreeSoftware
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Always wondered what the breakpoint was for and that helped out alot, now what was wrong with the code that i dont know lol i changed something and it started working. thx