New to Telerik Document ProcessingStart a free 30-day trial

Create archive from a list of files

Updated on Feb 19, 2026
Product VersionProductAuthor
2020.1.219RadZipLibraryDimitar Karamfilov

Description

You need to create an archive from a list of files.

Solution

Use RadZipLibrary to create and export the archive.

csharp
    List<string> fileNames = new List<string>();

    fileNames.Add("text.txt");
    fileNames.Add("text1.txt");
    fileNames.Add("text2.txt");

    string zipFileName = "Result.zip";

    using (Stream stream = File.Open(zipFileName, FileMode.Create))
    {
        using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, leaveOpen: true, entryNameEncoding: null))
        {
            foreach (var file in fileNames)
            {
                using (ZipArchiveEntry entry = archive.CreateEntry(file))
                {
                    var entryStream = entry.Open();
                    FileStream fs = new FileStream(file, FileMode.Open);
                    fs.CopyTo(entryStream);
                    entryStream.Flush();

                    fs.Close();
                    fs.Dispose();
                }
            }
        }
    }
In this article
DescriptionSolution
Not finding the help you need?
Contact Support