In projects starting from .Net 4.5, we can introduce the System.IO.Compression and System.IO.Compression.FileSystem (required to use the static class ZipFile) assemblies In this case, it is easy to compress the entire directory using the following static method: ZipFile.CreateFromDirectory //Note that the System.IO.Compression.FileSystem assembly needs to be introduced For projects before .Net 4.5, third-party compression libraries […]
Tag: sharpziplib
C# uses ICSharpCode.SharpZipLib to decompress and compress ZIP files
Use ICSharpCode.SharpZipLib to decompress and compress ZIP files Because there are a lot of codes on the Internet, I didn’t intend to post the codes, but when I use the codes on the Internet, there are various pitfalls, such as the directory when decompressing and the compressed package are fundamentally inconsistent, and the relative path […]
Use ICSharpCode.SharpZipLib to compress and decompress
add reference using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Checksums; Compression and decompression class public class ZipHelper { /// <summary> /// ZIP: Decompress a zip file /// </summary> /// <param name=”ZipFile”>The Zip file to be decompressed (absolute path)</param> /// <param name=”TargetDirectory”>Decompressed directory</param> /// <param name=”Password”>Decompression password</param> /// <param name=”OverWrite”>Whether to overwrite existing files</param> public static void UnZip(string ZipFile, string […]