wZip.cs
using System; using System.IO; using System.IO.Compression; public class WZip { public WZip() { } public void zipFromDirectory(string dir, string zipFile) { ZipFile.CreateFromDirectory(dir, zipFile); } public void unzipToDirectory(string zipFile, string dir) { ZipFile.ExtractToDirectory(zipFile, dir); } public void zipAddFile(string zipFile, string file, string entryName) { using( ZipArchive archive = ZipFile.Open(zipFile, ZipArchiveMode.Update) ) { archive.CreateEntryFromFile(file, entryName); //archive.ExtractToDirectory(extractPath); } } public void zipExtractFile(string zipFile, string file, string entryName) { using( ZipArchive archive = ZipFile.OpenRead(zipFile) ) { foreach (ZipArchiveEntry entry in archive.Entries) { //if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase)) { if( entry.FullName.Equals( entryName ) ) { entry.ExtractToFile(file); } } } } }
댓글 없음:
댓글 쓰기