IRONSOFTWAREHOME
Add Files to ZIP
using IronZip;

// Open an existing ZIP
using (var archive = IronZipArchive.FromFile("existing.zip"))
{
    // Add files
    archive.Add("./assets/image3.png");
    archive.Add("./assets/image4.png");

    // Export the ZIP
    archive.SaveAs("result.zip");
}
Imports IronZip

' Open an existing ZIP
Using archive = IronZipArchive.FromFile("existing.zip")
    ' Add files
    archive.Add("./assets/image3.png")
    archive.Add("./assets/image4.png")

    ' Export the ZIP
    archive.SaveAs("result.zip")
End Using
NuGet Download
PM > Install-Package IronZip
Add Files to ZIP

Add Files to ZIP

Users often face the challenge of adding new files to existing ZIP archives. The typical process involves extracting the current archive, adding new files, and compressing everything into a new ZIP file. This method is cumbersome and time-consuming, especially when dealing with multiple ZIP archives.

A more efficient solution is to utilize a library that allows for programmatic manipulation of ZIP files. IronZip excels in this regard with its powerful Add method, enabling users to integrate new files seamlessly without requiring extraction. In the following code example, we will demonstrate the intuitive nature of the Add method, showcasing how effortlessly it allows you to append new files to existing ZIP archives with just a few lines of code.

Accessing Existing ZIP to Add Files

We first import the namespace IronZip. Afterward, we initialize a new IronZipArchive class and using the FromFile method input one parameter: the path to the ZIP you're trying to access. Do note that the operation will fail if the path is incorrect.

Adding Files

After accessing the ZIP file, we can then add files to it. We call the Add method to add new files to the existing ZIP. The method takes in one parameter, which is the path to the file you wish to add; similar to above, the operation will fail if the path provided is incorrect. Within the example, we provide two file path images, image3.png and image4.png, and add them to the existing ZIP with Add.

Aside from adding PNG, IronZIP also supports various file types compatible with the Add method. Users can also add other popular image formats such as jpg, svg, and even multi-frame images such as tiff and gif. Other files such as text files, documents (PDF, DOCX, XLSX), and audio files (MP3 and WAV) are also supported; even adding ZIP archives within a ZIP archive is supported, making it versatile. For a complete list of files you can add, please refer here.

Exporting the ZIP

Finally, after adding the files to the existing ZIP, we call the SaveAs and provide a new name for the ZIP archive with the newly added files.

Learn How to Create, Read, and Extract ZIP Archives
View on GitHub

Ready to Get Started?

Nuget Downloads 23,187Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required