P
pubdude2003
hey all,
I have written a small db that downloads zip files from a site and then
automatically creates a directory and unzips a file into that directory,
except the last bit doesn't seem to be working. It does it all but the
unzipping. The debug indicates it should work but no such luck.
The portion of the code that unzips definitely works because I use the exact
same snippet in a loop in another form, fires fine.
Any thoughts would be appreciated.
On Error GoTo ErrHandler
Dim cnts1 As String
Dim cnts2 As String
Dim strPath As String
Dim strPath2 As String
Dim aFolders() As String
Dim I As Integer
Dim objHTTP As HTTP
Set rs = Me.RecordsetClone
If Not rs.EOF Then rs.MoveFirst
While Not rs.EOF
rs.Edit
cnts1 = InStr(rs!Contents, "http://tpod.dirxion.com/results.asp?jobid=")
cnts2 = Mid$(rs!Contents, cnts1 + 42, 5)
Set objHTTP = New HTTP
With objHTTP
.HttpURL = "http://www.someplace.com/hunterpool/" & cnts2 & ".zip"
.DestinationFile = "C:\2\" & cnts2 & ".zip"
'.PromptWithCommonDialog = True
If .FileExists Then .OverwriteTarget = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToHTTPHost
.WriteHTTPDataToFile
End With
rs![Content Unread] = 20 'just a box that turns red when this record is
done
rs.Update
strPath = "C:/1/"
strPath = strPath + cnts2
aFolders = Split(strPath, "\")
strPath = vbNullString
For I = LBound(aFolders) To UBound(aFolders)
strPath = strPath & aFolders(I)
If Len(Dir(strPath, vbDirectory)) = 0 Then
MkDir strPath
End If
strPath = strPath & "/"
Next I
DoEvents
strPath2 = ("C:\2\" & cnts2 & ".zip")
Call UnzipIt(strPath2, strPath)
Debug.Print UnzipIt(strPath2, strPath)
rs.MoveNext
Wend
Requery
rs.Close
Set rs = Nothing
ExitHere:
On Error Resume Next
Set objHTTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
Exit Sub
ErrHandler:
If Err.Number = 6 Then
Resume
End If
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, Err.
source
Resume ExitHere
debug
C:\2\88888.zip
C:/1/88888/
C:\2\88888.zip
C:/1/88888/
False
I have written a small db that downloads zip files from a site and then
automatically creates a directory and unzips a file into that directory,
except the last bit doesn't seem to be working. It does it all but the
unzipping. The debug indicates it should work but no such luck.
The portion of the code that unzips definitely works because I use the exact
same snippet in a loop in another form, fires fine.
Any thoughts would be appreciated.
On Error GoTo ErrHandler
Dim cnts1 As String
Dim cnts2 As String
Dim strPath As String
Dim strPath2 As String
Dim aFolders() As String
Dim I As Integer
Dim objHTTP As HTTP
Set rs = Me.RecordsetClone
If Not rs.EOF Then rs.MoveFirst
While Not rs.EOF
rs.Edit
cnts1 = InStr(rs!Contents, "http://tpod.dirxion.com/results.asp?jobid=")
cnts2 = Mid$(rs!Contents, cnts1 + 42, 5)
Set objHTTP = New HTTP
With objHTTP
.HttpURL = "http://www.someplace.com/hunterpool/" & cnts2 & ".zip"
.DestinationFile = "C:\2\" & cnts2 & ".zip"
'.PromptWithCommonDialog = True
If .FileExists Then .OverwriteTarget = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToHTTPHost
.WriteHTTPDataToFile
End With
rs![Content Unread] = 20 'just a box that turns red when this record is
done
rs.Update
strPath = "C:/1/"
strPath = strPath + cnts2
aFolders = Split(strPath, "\")
strPath = vbNullString
For I = LBound(aFolders) To UBound(aFolders)
strPath = strPath & aFolders(I)
If Len(Dir(strPath, vbDirectory)) = 0 Then
MkDir strPath
End If
strPath = strPath & "/"
Next I
DoEvents
strPath2 = ("C:\2\" & cnts2 & ".zip")
Call UnzipIt(strPath2, strPath)
Debug.Print UnzipIt(strPath2, strPath)
rs.MoveNext
Wend
Requery
rs.Close
Set rs = Nothing
ExitHere:
On Error Resume Next
Set objHTTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
Exit Sub
ErrHandler:
If Err.Number = 6 Then
Resume
End If
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, Err.
source
Resume ExitHere
debug
C:\2\88888.zip
C:/1/88888/
C:\2\88888.zip
C:/1/88888/
False