login about faq

Hello,

Have it now tried with OpenZip, here too, the files are not overwritten.

What am I doing wrong? the file is now available 3x in the ZIP Archiv. The files are always added only? I have no error. What should I do to overwrite an existing file in Zip_Archiv? Before deleting? Please help.

Thx

Christian

Here's my attempt:


Public Sub Zip_toFileZip(sSourceFile As String) Dim saveExtraPath As Boolean Dim sZipFile As String Dim success As Long

Set Zip2 = New Chilkat_v9_5_0.ChilkatZip

sZipFile = ArchivPfad 'Global Varialble

success = Zip2.UnlockComponent("xxxxxxxxxxxxxxxxxxxxxxx")

If (success <> 1) Then

Text1.Text = Text1.Text & "Failed to unlock zip!"

Exit Sub

End If

success = Zip2.OpenZip(sZipFile)

Zip2.OverwriteExisting = True

saveExtraPath = False

success = Zip2.AppendOneFileOrDir(sSourceFile, saveExtraPath)

If (success <> 1) Then

MsgBox Zip2.LastErrorText

Exit Sub

End If

success = Zip2.WriteZipAndClose()

If (success <> 1) Then

MsgBox Zip2.LastErrorText

Exit Sub

End If

Set Zip2 = Nothing

end sub

asked Jun 13 '15 at 05:15

Christian's gravatar image

Christian
(suspended)


This example shows how to overwrite files and inserting into subfolders. Here is my example for your collection VB6:

Public Sub File_toZip (sZipFile as string, sSourceFile As String, sSourcePfad As String, Subdir As String)

Dim saveExtraPath As Boolean

Dim Success As Long

Set Zip2 = New Chilkat_v9_5_0.ChilkatZip

success = Zip2.UnlockComponent ("xxxxxxxxxxxx")

If (success <> 1) Then

MsgBox Zip2.LastErrorText

GoTo err

End If

success = Zip2.OpenZip (sZipFile)

If (success <> 1) Then

MsgBox Zip2.LastErrorText

GoTo err

End If

Dim entry As ChilkatZipEntry

Set entry = Zip2.GetEntryByName (Subdir & sSourceFile)

If Not entry Is Nothing Then

If MsgBox (File & "is already exist." + VbNewLine + "Overwriting?" VbYesNo + vbQuestion) = vbNo Then

GoTo err

Else

Zip2.DeleteEntry entry

End If

End If

saveExtraPath = False Zip2.PathPrefix = Subdir

success = Zip2.AppendOneFileOrDir (sSourcePfad & sSourceFile, saveExtraPath)

If (success <> 1) Then

MsgBox Zip2.LastErrorText

GoTo err

End If

success = Zip2.WriteZipAndClose ()

If (success <> 1) Then

MsgBox Zip2.LastErrorText

End If

err:

Set Zip2 = Nothing

End Sub

link

answered Jun 15 '15 at 03:38

Christian's gravatar image

Christian
(suspended)

The OverwriteExisting property applies to unzipping zip files. It does not apply to appending files to an existing zip object. See the online reference documentation:

Determines whether existing files are overwritten during unzipping. The default is true, which means that already-existing files will be overwritten. Set this property = false to prevent existing files from being overwritten when unzipping.

link

answered Jun 13 '15 at 11:37

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

OK, so what can i do to overwtrite Files to existing ZiP? This must somehow be possible? Deleting bevor?

link

answered Jun 13 '15 at 12:01

Christian's gravatar image

Christian
(suspended)

To overwrite files in an existing zip, open the zip, remove the files that are to be overwritten, and then append files. The Chilkat Zip API provides methods for iterating over entries, finding entries, removing entries from the zip object, etc. See the online reference documentation.

link

answered Jun 14 '15 at 09:56

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×87

Asked: Jun 13 '15 at 05:15

Seen: 1,162 times

Last updated: Jun 15 '15 at 03:38

powered by OSQA