Jeh*_*hof 14
您可以使用DotNetZip来实现这一目标.它可以在任何应用程序中自由使用.
这是一些示例代码:
try
{
// for easy disposal
using (ZipFile zip = new ZipFile())
{
// add this map file into the "images" directory in the zip archive
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
// add the report into a different directory in the archive
zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
zip.AddFile("ReadMe.txt");
zip.Save("MyZipFile.zip");
}
}
catch (System.Exception ex1)
{
System.Console.Error.WriteLine("exception: " + ex1);
}
Run Code Online (Sandbox Code Playgroud)
否则,使用Ionic.
命名空间是System.IO.Packaging.ZIPPackage
.
有关故事,请参见http://visualstudiomagazine.com/articles/2012/05/21/net-framework-gets-zip.aspx.
归档时间: |
|
查看次数: |
6802 次 |
最近记录: |