zip compression

  • Thread starter David McLaughlin
  • Start date
D

David McLaughlin

hi there

got a small problem using J# lib in my c# application using Java.Util.Zip, I
used an example from the java.sun website seems to work fine compressing
small files from 1kb-100kb anything above causes a corruption in the zip
entry. Whenever I want to create an instance of the Zipfile to Unzip it
throws an exception reading any zipentries from the file.

I can also compress alot of small files as before and use WINZIP to extract
them perfectly, but again with the large files winzip displays a bad CRC
error.

If anyone has had a similar problem using java zip your help would much
appreciated.

Thanks
David McLaughlin

public static void Zip(string[] fNames, string ZipName)

{

string tmpFile = System.IO.Path.GetTempFileName();

FileOutputStream fout = new FileOutputStream(tmpFile);

ZipOutputStream to = new ZipOutputStream(new
BufferedOutputStream(fout));

BufferedInputStream source = null;

try

{

int BUFFSIZE = 8192;

sbyte[] buffer = new sbyte[BUFFSIZE];

int f = fNames.Length;

int count;


// Add file entries

for (int i = 0; i < f; i++)

{

FileInputStream s = new FileInputStream(fNames);

source = new BufferedInputStream(s, BUFFSIZE);


ZipEntry ze = new ZipEntry(fNames);

ze.setMethod(ZipEntry.DEFLATED);


to.putNextEntry(ze);

// Reset Counter

while((count = source.read(buffer, 0, BUFFSIZE)) != -1)

{

to.write(buffer, 0, count);

}

source.close();

}

to.close();

}

catch(Exception e)

{

MessageBox.Show(e.Message, "FinWin Backup", MessageBoxButtons.OK,
MessageBoxIcon.Error);

}

System.IO.File.Copy(tmpFile, ZipName, true);

System.IO.File.Delete(tmpFile);

}
 
C

Champika Nirosh

Hi,

I know nothing about Java Zip but how about trying with SharpZipLib which is
free and working perfectly..

I am using it and I can help you on that ..

Nirosh.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Zip file using a stream 8
SharpZipLib 2
Ajax Update Progress control 1

Top