홀덤사이트Paris Sportif CryptoTous Les Sites De Paris Sportifs BelgiqueMeilleur Casino En Ligne BelgiqueCasino Sans Documents
Zip up a Folder with .NET 4.5 and Visual Studio 2012  
Friday, August 17, 2012 at 9:49PM
saveenr

This has never been easier!

First, ensure your project's Target Framework is set to .NET Framework 4.5

Snap00006a

 

Second, add a reference to System.IO.Compression.FileSystem

Snap00007

 

Finally, call System.IO.Compression.ZipFile.CreateFromDirectory(). There are several overloads for this static method. The example below covers the most typical usage to create a ZIP file from a folder.

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string src_folder = @"D:\stuff";
            string destfile = @"D:\stuff.zip";
            var compressionLevel = System.IO.Compression.CompressionLevel.Optimal;
            bool includebasedir = false;
            System.IO.Compression.ZipFile.CreateFromDirectory(src_folder,destfile,compressionLevel, includebasedir );
        }
    }
}

 

Article originally appeared on viziblr (http://viziblr.com/).
See website for complete article licensing information.

Other interesting websites