标签:files static var with ges extension sys stat file
using Ionic.Zip; public class ZipHelper { public static void ZipSingleFile(string zipPath) { try { using (ZipFile zip = new ZipFile()) { zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images"); zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files"); zip.AddFile("ReadMe.txt"); zip.Save(zipPath); } } catch (Exception ex) { System.Console.Error.WriteLine("exception: " + ex); } } public static void UnZipSingleFile(string path) { try { using (ZipFile zip = new ZipFile(path)) { var baseDir = Path.GetDirectoryName(path); var fileName = Path.GetFileNameWithoutExtension(path); var newDir = Path.Combine(baseDir, fileName); Directory.CreateDirectory(newDir); zip.ExtractAll(newDir, ExtractExistingFileAction.OverwriteSilently); } File.Delete(path); } catch(Exception ex) { System.Console.Error.WriteLine("exception: " + ex); } } }
标签:files static var with ges extension sys stat file
原文地址:https://www.cnblogs.com/dayang12525/p/9559471.html