Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Rename Files before UnzippingHow to rename files before unzipping. The .zip is opened, the filenames are updated (in memory) so that when the .zip is unzipped, the filenames are different. The original .zip is unmodified.
'
Dim zipObj As New Chilkat.Zip
zipObj.UnlockComponent("Anything for 30-day trial")
' Open a zip archive containing:
' inv.dbf
' cust.dbf
' rpt.dbf
' test.xml
' junk.txt
Dim success As Boolean
success = zipObj.OpenZip("testData.zip")
If (Not success) Then
MessageBox.Show(zipObj.LastErrorText)
Exit Sub
End If
' Loop over the entries and rename all files ending in .dbf:
Dim n As Integer
Dim i As Integer
Dim entry As Chilkat.ZipEntry
n = zipObj.NumEntries
For i = 0 To n - 1
entry = zipObj.GetEntryByIndex(i)
If (entry.FileName.EndsWith(".dbf")) Then
entry.FileName = entry.FileName.Replace(".dbf", "01.dbf")
End If
Next
' Now unzip all .dbf files:
n = zipObj.UnzipMatching("unzipDir", "*.dbf", False)
If (n < 0) Then
MsgBox(zipObj.LastErrorText)
Else
MsgBox(n.ToString() & " files unzipped!")
End If
' These files are created: cust01.dbf, rpt01.dbf, inv01.dbf
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.