Icsharpcode.sharpziplib Using Demo

xiaoxiao2021-04-06  288

Using system;

Using system.data;

Using system.io;

Using system.text;

Using ICsharpcode.sharpziplib.zip;

Namespace Test.cui

{

Class Zip

{

Static void compressfile ()

{

FILESTREAM INS = File.Openread ("1.jpg");

FILESTREAM OUTS = file.create ("Test.zip");

ZipoutputStream S = New ZipOutputStream (OUTS);

S.SetLevel (5);

S.password = "123456";

ZIPENTRY Entry = New Zipentry ("1.jpg");

S.putNextentry (entry);

Byte [] buffer = new byte [INS.LENGTH];

INS.READ (Buffer, 0, Buffer.Length);

S.Write (buffer, 0, buffer.length);

S.finish ();

s.close ();

}

Static MemoryStream UncompresStomemory ()

{

ZipinputStream S = New ZipinputStream (File.OpenRead ("Test.zip");

S.password = "123456";

Zipentry thentry = s.getnextentry ();

Console.writeLine (forentry.name);

MemoryStream MS = New MemoryStream ((int) thentry.size);

Byte [] Data = New Byte [1024 * 100];

While (True)

{

Int size = s.read (Data, 0, Data.Length);

IF (size> 0)

{

Ms.Write (DATA, 0, SIZE);

}

Else

{

Break;

}

}

Console.writeline (Ms.Length);

s.close ();

Return MS;

}

Static void upcompresstofile ()

{

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-132319.html

New Post(0)