thaburner
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.lblLatestV ersion.Cap tion = .FileVersion
frmUpdateScreen.lblLatVerR el.Caption = .ReleaseDate
frmUpdateScreen.lblFileSiz e.Caption = .FileSize
frmUpdateScreen.lblFilenam e.Caption = .FileName
DownloadFile FileSettings(s).DownloadPa th1, App.Path & "\" & FileSettings(s).FileName, frmUpdateScreen.Inet1
End If
End With
End Function
Public Sub DownloadFile(strSrcHTTPFil e As String, strDestSaveFile As String, objbInet As Inet)
m_DownloadingFile = False
m_DownloadingFileSize = GetHTTPFileSize(strSrcHTTP File, 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(strHTTPFil e 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
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.lblLatestV
frmUpdateScreen.lblLatVerR
frmUpdateScreen.lblFileSiz
frmUpdateScreen.lblFilenam
DownloadFile FileSettings(s).DownloadPa
End If
End With
End Function
Public Sub DownloadFile(strSrcHTTPFil
m_DownloadingFile = False
m_DownloadingFileSize = GetHTTPFileSize(strSrcHTTP
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(strHTTPFil
'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
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
ASKER
on the main window there is a start button which calls LoadUpdatesList and thats it in the button
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
how do you call this code?