Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Whats wrong with this zip File-> GetError: Wrong Local header signature: 0x140033

$
0
0

Hi 

i create a test project u can find it :

https://dl.dropboxusercontent.com/u/69535794/SharpLibZipTest.zip

under SharpLibZipTest\bin\Debug is a zip file ("o.zip") 

if i read the zip entries the first time i have no problems

but if i modify the zip file with sharplib i get an exception if i read the zipentries again:  Wrong Local header signature: 0x140033

with other zipfiles i have no problem with this code.

i use sharplibzip 0.86.0.518

here the code to read the zipentries:

   public void ReadZipEntries()

    {

      try

      {

        using (ZipInputStream tInput = new ZipInputStream(File.Open(mFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))

        {

          ZipEntry tEntry;

          while ((tEntry = tInput.GetNextEntry()) != null)

          {

            System.Console.WriteLine(tEntry.Name);

          }

        }

      }

      catch (Exception error)

      {

        System.Console.WriteLine("Error: {0}", error.Message.ToString());

      }

      System.Console.WriteLine("readEntrysDone");

    }

 

  public void RemoveFirstZipEntry()

    {

      ZipFile tZipFile = null;

      MemoryStream ms = new MemoryStream();

      mProjectStream.Position = 0;

      ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(mProjectStream, ms, new byte[4096]);

      ms.Position = 0;

      tZipFile = new ZipFile(ms);

      tZipFile.IsStreamOwner = false;

      ZipEntry tZipEntry = null;

      if (tZipFile.Count > 0)

        tZipEntry = tZipFile[0];

      if (tZipEntry != null)

      {

        tZipFile.BeginUpdate();

        tZipFile.Delete(tZipEntry);

        tZipFile.CommitUpdate();

      }

      tZipFile.Close();

      ms.Position = 0;

      mProjectStream.Position = 0;

      mProjectStream.SetLength(0);

      ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(ms, mProjectStream, new byte[4096]);

      mProjectStream.Flush();

    }

the rest of the code u can find it in the SharpLibZipTest.zip

thx

 

 

 


Viewing all articles
Browse latest Browse all 1764

Trending Articles