I found this code to call the zLib1.dll but how
can I specify a file to compress and specify the file name compressed.
And the same case to uncompress?
C# 4.0
[DllImport("zlib1.dll", CallingConvention=CallingConvention.Cdecl) ]
static extern int compress(byte[] destBuffer, ref uint destLen, byte[] sourceBuffer, uint sourceLen);
[DllImport("zlib1.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int uncompress(byte[] destBuffer, ref uint destLen, byte[] sourceBuffer, uint sourceLen);
public static byte[] Compress(byte[] data)
{
uint _dLen = (uint)((data.Length * 1.1) + 12);
byte[] _d = new byte[_dLen];
compress(_d, ref _dLen, data, (uint)data.Length);
byte[] result = new byte[_dLen];
Array.Copy(_d, 0, result, 0, result.Length);
return result;
}
public static byte[] Decompress(byte[] data)
{
uint _dLen = 8192;
byte[] _d = new byte[_dLen];
if (uncompress(_d, ref _dLen, data, (uint)data.Length) != 0)
return null;
byte[] result = new byte[_dLen];
Array.Copy(_d, 0, result, 0, result.Length);
return result;
}
[Edited]Code is blocked in "pre" tags[/Edited]