SharpZipLib

  • Thread starter Thread starter John
  • Start date Start date
J

John

Did anyone use SharpZipLib on the Compact Framework? The docs say that
the support is added. However I am getting a MissingMethodException on
the Read method of ZipInputStream.

Thanks.
 
SharpZLib is compiled against full framework and won't run on the CF because
it references couple of things that are missing from CF. Aside of that it
references wrong system assemblies. I was able to recompile it very quickly
for CF. All that I had to do was to replace calls to Console.Error with
Console and remove attempt to use BufferedStream. The rest is obvious.
Unfortunately I cannot post the results as it would violate GPL, but the
process is really straightforward.
 
Thanks Alex,
I recompiled with only the Zip code. Worked fine. That way, didn't
even have to remove the code you mentioned plus that cut the assembly
to half the size.

I am testing it now with some dummy data, 1000 files in a 7 MB zip
file. It is taking 17 sec for the ZipFile class to open it on the
emulator. I am using ZipFile class instead of the ZipInputStream class
since I need to extract specific files. So I need
ZipFile.GetInputStream(ZipEntry) rather than
ZipInputStream.GetNextEntry();

Is this delay normal? Seems a bit too long even if it is only once. Is
there a more efficient way to do it?

Thanks again.
 
It's probably the time required to read the zip directory. Or could it be
that you are seing the time it takes to JIT-compile this (rather larger)
library?
 
The best way to answer that is to actually read the GPL, which I highly
recommend. In this case the short is that you can freely modify it, but the
modifications must be made public. I'm not sure what the implications are
on something that uses the new library. Again, this is where reading the
GPL would come in.

-Chris
 
Dear John,

Could you provide me some source samples, howto extract a file on CF

I also recompiled the ZipLib.

But I'm stil getting a missingmethod exception.

This is my source (VB .NET)

----------------------------------------------------------------------------
-----------
Private Sub Unzip(ByVal zipFile As String, ByVal UnzipToFolder As String)
Dim nByte As Integer
Dim s As New ZipInputStream(File.OpenRead(zipFile))
Dim entry As ZipEntry
Dim Zip_Data(2048) As Byte
Zip_Data(2048) = New Byte

entry = s.GetNextEntry

Do

Dim fs As New FileStream(Path.Combine(UnzipToFolder,
Path.GetFileName(entry.Name)), FileMode.Create)

Dim bw As New BinaryWriter(fs, System.Text.Encoding.ASCII)

nByte = s.Read(Zip_Data, 0, Zip_Data.GetLength(0))

While nByte > 0
bw.Write(Zip_Data, 0, nByte)
nByte = s.Read(Zip_Data, 0, Zip_Data.GetLength(0))
End While

fs.Close()
bw.Close()
entry = s.GetNextEntry

Loop While Not (entry Is Nothing)

s.Close()

End Sub

Thanx in advance
 
Eelco Akker said:
Dear John,

Could you provide me some source samples, howto extract a file on CF

I also recompiled the ZipLib.

But I'm stil getting a missingmethod exception.

This is my source (VB .NET)

Sure Eelco!
Here is my C# snippet

zFile = new ZipFile(@"/Program Files/ZipTestCFCS/z.zip");
ZipEntry MyEntry = zFile.GetEntry("1.txt");

Stream s = zFile.GetInputStream(MyEntry);
int length = Convert.ToInt32(MyEntry.Size);
byte[] ba = new byte[length];
s.Read(ba, 0, length);

Encoding ascii = Encoding.ASCII;
char[] asciiChars = new char[ascii.GetCharCount(ba, 0, ba.Length)];
ascii.GetChars(ba, 0, ba.Length, asciiChars, 0);
return new string(asciiChars);

I did not do anything particularly creative for compiling the lib.
Just created a new project for a Pocket PC lib, drag-dropped Zip and
Checksums folders from the windows explorer to the solution and
compiled.

I can mail you the source of the project and the binary if you want.
That shouldn't violate GPL.
 
Thanx you very much John for your help, I don't need your source and bin.
now, it already works.

That did the trick.

I made a manual for it and posted it to the forum of ICSharp.ZibLib.

Greets,

Eelco


John said:
"Eelco Akker" <[email protected]> wrote in message
Dear John,

Could you provide me some source samples, howto extract a file on CF

I also recompiled the ZipLib.

But I'm stil getting a missingmethod exception.

This is my source (VB .NET)

Sure Eelco!
Here is my C# snippet

zFile = new ZipFile(@"/Program Files/ZipTestCFCS/z.zip");
ZipEntry MyEntry = zFile.GetEntry("1.txt");

Stream s = zFile.GetInputStream(MyEntry);
int length = Convert.ToInt32(MyEntry.Size);
byte[] ba = new byte[length];
s.Read(ba, 0, length);

Encoding ascii = Encoding.ASCII;
char[] asciiChars = new char[ascii.GetCharCount(ba, 0, ba.Length)];
ascii.GetChars(ba, 0, ba.Length, asciiChars, 0);
return new string(asciiChars);

I did not do anything particularly creative for compiling the lib.
Just created a new project for a Pocket PC lib, drag-dropped Zip and
Checksums folders from the windows explorer to the solution and
compiled.

I can mail you the source of the project and the binary if you want.
That shouldn't violate GPL.
 
John said:
Did anyone use SharpZipLib on the Compact Framework? The docs say that
the support is added. However I am getting a MissingMethodException on
the Read method of ZipInputStream.

I've only used the GZIP-support, but that works perfectly fine without
any hassles or modifications. Almost like Java ;-)

david
--
Auch das geht vorüber. (Sufi-Weisheit)

Holger (David) Wagner Tel: +49 (89) 890 50 962
Dewetstrasse 1 Mobil: +49 (177) 274 12 45
D-80807 München Fax: +49 (177) 992741245
 
Back
Top