473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

zip compression

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[i]);

source = new BufferedInputStream(s, BUFFSIZE);
ZipEntry ze = new ZipEntry(fNames[i]);

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);

}


Nov 15 '05 #1
1 1368
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.

"David McLaughlin" <te**@datawave.com.au1> wrote in message
news:eR**************@TK2MSFTNGP11.phx.gbl...
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[i]);

source = new BufferedInputStream(s, BUFFSIZE);
ZipEntry ze = new ZipEntry(fNames[i]);

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);

}

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim Hubbard | last post by:
I went to the compression newsgroups, but all I saw was spam. So, I thought I'd post his question here to get the best info I could from other programmers. Which compression algorithm offers...
1
by: Maurice Mertens | last post by:
Hello, I'm having troubles with saving a tiff-file with a certain compression and colordepth. This is the code I use: ----------------------------------------------------------------------...
8
by: Anurag | last post by:
Hi, I am told that Oracle has this "data compression" feature that allows you to store online data ina compressed format. This is different from archived data - you compress only that data which...
2
by: deko | last post by:
Is it best practice to set Unicode Compression to "No" for memo fields in a table? What about text fields? According to the VB help entry: "Data in a Memo field is not compressed unless it...
17
by: dunric | last post by:
After writing the computing urban legend "The Helsinki Code", I spent several nights thinking up how in the world Gustav Larsson, the Finnish PDP-8 computer programmer, could have managed to...
1
by: chris.atlee | last post by:
I'm writing a program in python that creates tar files of a certain maximum size (to fit onto CD/DVD). One of the problems I'm running into is that when using compression, it's pretty much...
3
by: Benny Ng | last post by:
Dear All, Now I met some performance problems in my application. Because according to our business. The size of some web forms are larger than 1xxx MB. So it takes a long time for user opening a...
20
by: chance | last post by:
Hello, I want to add compression to a memory stream and save it in an Oracle database. This is the code I have so far: //save the Word document to a binary field, MemoryStream dataStream = new...
21
by: =?Utf-8?B?VkJB?= | last post by:
I compressed a file with GZipStream class and is larger than the original file.... how can this be?, the original file is 737 KB and the "compressed" file is 1.1 MB. Did i miss something or is...
3
by: GiJeet | last post by:
Hello, we have an app that scans documents into TIFF format and we need to transfer them over the internet. If anyone knows of a SDK we can use that can compress TIFFs on the fly or even if it can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.