问题描述
我在我们存储与DynaZip最大安全,使用下面的代码压缩的PDF文件的数据库:
I have a database in which we stored pdf files compressed with DynaZip Max Secure, using the following code:
MemoryStream msIN = new System.IO.MemoryStream(); //Input MemoryStream
MemoryStream msZip = new System.IO.MemoryStream(); //Compressed MemoryStream
BinaryReader objBinaryReader;
BinaryWriter objBinaryWriter;
public MemoryStream CompressStream(byte[] vbuf)
{
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(msIN);
bw.Write(vbuf);
CDZipSNET dz1 = new CDZipSNET();
dz1.ZipMemToMemCallback += new CDZipSNET.OnZipMemToMemCallback(this.ZipMemToMemCallback_event);
dz1.ActionDZ = CDZipSNET.DZACTION.ZIP_MEMTOMEM;
return msZip;
}
这是ZipMemToMemCallback_event代码:
And this is the ZipMemToMemCallback_event code:
public void ZipMemToMemCallback_event(CDZipSNET.MEMTOMEMACTION lAction,ref byte[] lpMemBuf,ref uint pdwSize,uint dwTotalReadL,uint dwTotalReadH,uint dwTotalWrittenL,uint dwTotalWrittenH,ref CDZipSNET.MEMTOMEMRESPONSE plRet)
{
int bytesToRead;
switch(lAction)
{
case CDZipSNET.MEMTOMEMACTION.MEM_READ_DATA:
if((dwTotalReadL == 0) && (dwTotalReadH == 0))
{
msIN.Seek(0, System.IO.SeekOrigin.Begin);
objBinaryReader = new System.IO.BinaryReader(msIN);
}
try
{
bytesToRead = (int)(objBinaryReader.BaseStream.Length - dwTotalReadL);
if(bytesToRead > pdwSize)
{
bytesToRead = (int)pdwSize;
plRet = CDZipSNET.MEMTOMEMRESPONSE.MEM_CONTINUE;
}
else
{
plRet = CDZipSNET.MEMTOMEMRESPONSE.MEM_DONE;
}
pdwSize = (uint)bytesToRead;
if(bytesToRead > 0)
{
objBinaryReader.Read(lpMemBuf, 0, bytesToRead);
}
}
catch
{
plRet = CDZipSNET.MEMTOMEMRESPONSE.MEM_ERROR;
}
break;
case CDZipSNET.MEMTOMEMACTION.MEM_WRITE_DATA:
if((dwTotalWrittenL == 0) && (dwTotalWrittenH == 0))
{
objBinaryWriter = new System.IO.BinaryWriter(msZip);
}
try
{
objBinaryWriter.Write(lpMemBuf, 0, (int)pdwSize);
plRet = CDZipSNET.MEMTOMEMRESPONSE.MEM_CONTINUE;
}
catch (System.Exception)
{
plRet = CDZipSNET.MEMTOMEMRESPONSE.MEM_ERROR;
}
break;
default: plRet = CDZipSNET.MEMTOMEMRESPONSE.MEM_ERROR;
break;
}
}
我会提供别的必要anwser这个谜团,香港专业教育学院尝试定期邮编解压缩,Zlib压缩,Gzip已无济于事。我感谢所有帮助。谢谢你
I will provide anything else necessary to anwser this riddle, Ive tried regular Zip decompressing, Zlib, Gzip to no avail. I will appreciate any help. Thank You.
编辑:的问题是,DinaZip是propietary,停产库,没有帮助或故障排除通过释放出它的公司,我commisioned解压缩一堆使用这个库(与代码avobe)先前的压缩文件,我不再有可用于解压缩库,我不知道是否有人知道任何方式来解压缩文件,这可能使用第三方库。或方法
The problem is that DinaZip is a propietary, discontinued library, with no help or troubleshooting by the company that released it, I'm commisioned to decompress a bunch of files that were previously compressed using this library (with the code avobe) and I no longer have the library available for decompression, I wonder if anyone knows any way to decompress this files maybe using another library or method.
推荐答案
此代码是从它可以解压缩加密DynaZip流:
This code is from https://zlibnet.codeplex.com and it can decompress unencrypted DynaZip streams:
public static class DynazipCompressor
{
const int DZ_DEFLATE_POS = 46;
public static bool IsDynazip(byte[] source)
{
return source.Length >= 4 && BitConverter.ToInt32(source, 0) == 0x02014b50;
}
public static byte[] DeCompress(byte[] source)
{
if (!IsDynazip(source))
throw new InvalidDataException("not dynazip header");
using (MemoryStream srcStream = new MemoryStream(source, DZ_DEFLATE_POS, source.Length - DZ_DEFLATE_POS))
using (MemoryStream dstStream = DeCompress(srcStream))
return dstStream.ToArray();
}
private static MemoryStream DeCompress(Stream source)
{
MemoryStream dest = new MemoryStream();
DeCompress(source, dest);
dest.Position = 0;
return dest;
}
private static void DeCompress(Stream source, Stream dest)
{
using (DeflateStream zsSource = new DeflateStream(source, CompressionMode.Decompress, true))
{
zsSource.CopyTo(dest);
}
}
}
一个DynaZip流是一个简单的与PKZIP头DeflateStream,所以这个代码只是跳过头。
A DynaZip stream is simply a DeflateStream with a PKZIP header, so this code just skip the header.
这篇关于有没有办法来解压缩与另一个库DynaZip最大文件? F.E. DotNetZip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!