Creating zip64 with Powershell Assembly method

Oct 6, 2010 at 4:12 PM

I suspect this is a very easy question, but I'm banging my head on the syntax.  I simply want to always use zip64 option in creating zips with my Powershell script.  Here's the script I'm using:

[System.Reflection.Assembly]::LoadFrom("c:\temp\Ionic.Zip.dll");
$zip =  new-object Ionic.Zip.ZipFile
$zip.Zip64Option.Always
$zip.AddFile("C:\temp\test.txt");
$zip.Save("C:\temp\test.zip")
$zip.Dispose()

But the "Is Zip64?" always still says false.

Any suggestions?

Thanks!

Emo

Oct 6, 2010 at 4:46 PM

Unless I'm looking at this the wrong way.  I guess that's the file properties before it's zipped?

And, should the syntax be "$zip.UseZip64WhenSaving = [Ionic.Zip.Zip64Option]::Always"?

Oct 6, 2010 at 7:33 PM

Well it looks like either one works ($zip.Zip64Option.Always or $zip.UseZip64WhenSaving = [Ionic.Zip.Zip64Option]::Always)...as if I take the line out altogether, and try to zip over 4 gigs it errors out and suggests using zip64.  And if I use either of those two line, it works.

Guess I might have answered my own question :)

Coordinator
Oct 7, 2010 at 2:51 AM
Edited Oct 14, 2010 at 10:01 PM

Thanks for asking answering your own question. The IsZip64 property is really only valid for zipfiles that get read. You are creating or writing a zip file.

There is some confusion about which properties apply, when... This is why I named the property in question with the ...WhenSaving suffix. I was attempting to be clear about when that property would have an effect.

Side note: The problem is, there are numerous phases - reading, saving, etc. Eliminating that confusion is a goal of the v2.0 DotNetZip, which will organize saving and reading options into separate buckets, to be more explicit about when they apply.  The save bucket will be called SaveOptions, I think.  So you'll have a property like SaveOptions.UseZip64, and so on.