C# Language Reading and writing .zip files Writing to a zip file

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

To write a new .zip file:

System.IO.Compression
System.IO.Compression.FileSystem

using (FileStream zipToOpen = new FileStream(@"C:\temp", FileMode.Open)) 
{
    using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update)) 
    {
        ZipArchiveEntry readmeEntry = archive.CreateEntry("Readme.txt");
        using (StreamWriter writer = new StreamWriter(readmeEntry.Open())) 
        {
            writer.WriteLine("Information about this package.");
            writer.WriteLine("========================");
        }
    }
}


Got any C# Language Question?