This project is read-only.

Problems with powershell and Ionic .Net Zip

Jul 13, 2009 at 8:30 PM

Everything has been working fine until about a day or two ago, where we get:

Exception calling "Save" with "0" argument(s): "An attempt was made to move the
 file pointer before the beginning of the file.

our code:


function ZipUp-File ( $file, $zipname )
Write-Output "Zipping $file to $zipname"

#Create new Zip Object
$zipfile =  new-object Ionic.Utils.Zip.ZipFile($zipname);
#Add the specified file to be zipped
echo "$file zipped successfully"
#Save the archive

 Nothing has changed at all. No code changes, no OS changes, nothing.

Any ideas as to what the cause is?



Jul 13, 2009 at 11:20 PM
Edited Jul 13, 2009 at 11:23 PM

yes, I have seen, and fixed, a similar sounding problem recently.

It happens as files get larger - bad pointer arithmetic inside the library.

I fixed it in v1.8.4.5.

What version of the library are you using?   If it is earlier than the latest 1.8, then can I suggest that you get the latest, and retry it?

The problem now is that your zip file may not be valid.  All the data is there, but the metadata is not correct - the file offsets for each of the compressed files.   You'll have to fix it up, using the new method ZipFile.CheckZip().    Call that method, once, on each zip file, using v1.8.4.5.  Then you won't have to call it again.  For large zip files it will take some time.  


Jul 14, 2009 at 12:40 PM

I was using 1.6

Using the newest version fixed it. I upgraded and its working like a champ. Thank you so much, especially for the quick reply!