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