C#利用自带的ZipFile压缩和解压zip文件

//解压文件var zipPath = Directory.GetCurrentDirectory() +
 "/wwwroot/zippath/filename.zip";var newPath= Directory.GetCurrentDirectory() + 
"/wwwroot/newpath";ZipFile.ExtractToDirectory(newPath, zipPath, Encoding.UTF8, true); //压缩文件
var filePath = Directory.GetCurrentDirectory() + "/wwwroot/filepath";
var zipPath2 = Directory.GetCurrentDirectory() + 
"/wwwroot/zippath/filename2.zip";
ZipFile.CreateFromDirectory(filePath, zipPath2); //读取zip压缩文件里的文件
var filelist= ZipFile.OpenRead(zipPath).Entries.Select(s => s.Name).ToList();


 

你可能感兴趣的:(c#)