Вопрос

I need to archive(zip/compress...) a folder in my application I use .NET4?

I try to find examples in google,but I didnt find nothing.

Any idea how can I implement archiving of a folder in .NET4?

Это было полезно?

Решение

The DotNetZip library is very well documented and easy to use.
You can download the library (just one file) from here.

This example is all that you need to write

using (ZipFile zip = new ZipFile())
{
    zip.AddDirectory(@"MyDocuments\ProjectX", "ProjectX");
    zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G") ; 
    zip.Save(zipFileToCreate);
}

Другие советы

Check out SharpZipLib, you can get it on NuGet: https://nuget.org/packages/SharpZipLib/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top