0

i would copy files from one ZipFile to another ZipFile.

Why it issnt so easy?

' Copy files from b.zip to a.zip
Dim a As New ZipFile(CurDir() & "\a.zip")
Dim b As New ZipFile(CurDir() & "\b.zip")

a.BeginUpdate()

For Each c As ZipEntry In b
    a.Add(c) 'Error: ICSharpCode.SharpZipLib.Zip.ZipException - Entry cannot have any data
Next

a.CommitUpdate()
a.Close()

I use the https://github.com/icsharpcode/SharpZipLib Library on .NET 4.5 Visual Basic.

Could anyone give me a tip?

Patrick
  • 829
  • 2
  • 13
  • 34

1 Answers1

0

If your destination zip file is same as source then copy whole Zip file and Rename it, why your doing one by one files.........

andy
  • 5,979
  • 2
  • 27
  • 49
  • Content from a.zip: 1.txt Content from b.zip: 2.txt 3.txt I would test the system and i would know how i can opy single files from one zip archive to another zip archive. – Patrick Feb 23 '13 at 10:26
  • You need to use the libraries like SharpZipLib or DotNetZip. No need to unzip the file. – andy Feb 23 '13 at 10:42
  • Is there a example for ShareZipLib or DotNetZip how to copy files from one zip to other zip without unzip? I use ShareZipLib ^^ – Patrick Feb 23 '13 at 11:00
  • its in C# http://stackoverflow.com/questions/2987072/sharpziplib-can-you-add-a-file-without-it-copying-the-entire-zip-first – andy Feb 23 '13 at 11:01
  • Check [this](http://stackoverflow.com/questions/12107966/c-extract-a-zipped-file-only-without-the-folder) one also – andy Feb 23 '13 at 11:02
  • Now i tried to copy the files like your example andy. -> http://pastebin.com/w8Dz6jMa But it doesnt work... The file was added to file. YAY! But they have no content -.- (size = 0) If i remove .size = 0, i get the error like the person in your example... – Patrick Feb 23 '13 at 11:33
  • Now i solved this problem with rebuild the archiv... But i could not delete any entries -.- `a.Delete(a.EntryByIndex(a.FindEntry("test", True)))` <- FindEntry is != -1 ;) – Patrick Feb 23 '13 at 13:13