| In ASP: | |
 |
 |
In this very basic sample we are unzipping content of file "E:\projects\proj1.zip" to the folder "E:\proj1unziped\". If an error occurs it is outputed on the page
Dim z
Set z = Server.CreateObject("zbitz.zzip")
If z.UnzipFile("E:\projects\proj1.zip","E:\proj1unziped\")=0 Then
Response.Write "Success"
Else
Response.Write "Failure" & z.LastMsg
End If
|
 |
 |
In this sample we are adding files readme.htm and zbitz.dll
to the root (KeepDirNames=false) of the archive zbitz_trial.zip
and if an error occurs we want to see ALL (MsgLevel=0) the
messages that were obtained during atempted opperation
Dim z,iRes
Set z = Server.CreateObject("zbitz.zzip")
z.KeepDirNames = False
z.MsgLevel=0
iRes = z.ZipFile("D:\Documents\readme.htm;D:\Documents\zbitz.dll", _
"E:\projects\vc\zbitz\zbitz_trial.zip")
Response.Write "Result code is:" & iRes & "<br>"
If iRes <> 0 Then
Response.Write "Msgs: " & z.LastMsg
End If
|
 |
 |
In this sample we extract content of the "zbitz_trial.zip" archive
into the folder "d:\objects\zip\" and output the detailed
operation progress
Dim z,iRes
Set z = Server.CreateObject("zbitz.zzip")
z.MsgLevel=0
iRes=z.UnzipFile("E:\projects\vc\zbitz\zbitz_trial.zip", _
"d:\objects\zip\")
Response.Write "Res=" & iRes & "<br>Msgs: " & z.LastMsg & "<br>"
|
 |
 |
In this sample we create self-extracting archive "zip_v1.exe" by using "zbit_sfx.exe" stub.
We compress all the files and directories of subdirectory "out" ("out\*.*") under the directory
"D:\projects\design\allflorist\".
Dim z,iRes
Set z = Server.CreateObject("zbitz.zzip")
z.SFX="D:\obj\zbit_sfx.exe"
z.RootDir="D:\projects\design\allflorist\"
iRes=z.ZipFile("out\*.*","d:\obj\zips\zip_v1.exe")
Response.Write "Res=" & iRes & "<br>Msgs: " & z.LastMsg & "<br>"
|
 |
 |
In this sample we first test the archive's integrity. We then Get the detailed listing of the
files in the archive and format it a bit so that one file per line is displayed on an HTML page.
Dim zip,sFile,iRes
sFile="F:\projects\vbprog.zip"
Set zip = Server.CreateObject("zbitz.zzip")
zip.TestMode=1
iRes=zip.UnzipFile(sFile,"")
Response.Write "Test result=" & iRes & " (" & zip.LastMsg & ")<br>"
zip.TestMode=0
zip.InfoMode=5
iRes=zip.UnzipFile(sFile,"")
if iRes=0 Then
response.Write "Zip File Contents:<br>" & _
Replace(zip.LastMsg,vbLf,"<br>")
Else
response.Write "Error Getting Zip File Contents: " & _
iRes & "-" & zip.LastMsg
End if
Set zip = Nothing
|
 |
| In Visual Basic: |
 |
 |
In this sample we are adding file(s) described in txtFiles
text box to the archive which file name is in txtZip textbox.
The integer result is then show in lblResult and if is not Ok
(<>0) the error message is shown in lblErr label
Dim z As New zbitz.Czzip, iRes As Long
z.KeepDirNames = CBool(chkDirEntries.Value)
iRes = z.ZipFile(txtFiles.Text, txtZip.Text)
lblResult.Caption = iRes
If iRes <> 0 Then lblErr.Caption = z.LastMsg
|
 |
In this sample we first set InfoMode property to zbInfModeOnePLine (1)
to get the list the files in the archive. We then try to find a file (or
group of files) that we really want. If such file(s) found, we set IncludeList
property to be only the files we want (note the use of wild cart character) and
finally issue an unzip operation, not forgetting to set InfoMode property back
to zbInfModeNone (0). This is much more efficient than trying to extract all
the files in the archive and then see if the needed files were really there.
Dim sZipPath, sMyFile, iRes
Dim z As New zbitz.Czzip
sZipPath = "F:\projects\vbprog.zip"
sMyFile = "bitsetup"
z.InfoMode = zbInfModeOnePLine
iRes = z.UnzipFile(sZipPath, "")
If iRes = 0 Then
If InStr(1, z.LastMsg, sMyFile, vbTextCompare) > 0 Then
z.IncludeList = sMyFile & ".*"
z.InfoMode = zbInfModeNone
iRes = z.UnzipFile(sZipPath, App.Path & "\t")
MsgBox ("result= " & iRes & " - " & z.LastMsg)
Else
MsgBox ("File " & sMyFile & _
" is not found in the archive." & sZipPath)
End If
Else
MsgBox ("Error " & iRes & " - " & z.LastMsg)
End If
Set z = Nothing
|