C# – Create normal zip file programmatically


I have seen many tutorials on how to compress a single file in c#. But I need to be able to create a normal *.zip file out of more than just one file. Is there anything in .NET that can do this? What would you suggest (baring in mind I'm under strict rules and cannot use other libraries)

Thank you

Best Solution

Just an update on this for anyone else who stumbles across this question.

Starting in .NET 4.5 you are able to compress a directory using System.IO.Compression into a zip file. You have to add System.IO.Compression.FileSystem as a reference as it is not referenced by default. Then you can write:

System.IO.Compression.ZipFile.CreateFromDirectory(dirPath, zipFile);

The only potential problem is that this assembly is not available for Windows Store Apps.