# Create archive from a list of files

## Environment

| Product Version | Product       | Author                                                                        |
| --------------- | ------------- | ----------------------------------------------------------------------------- |
| 2020.1.219      | RadZipLibrary | [Dimitar Karamfilov](https://www.telerik.com/blogs/author/dimitar-karamfilov) |

## Description

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

## Solution

Use [RadZipLibrary](https://www.telerik.com/document-processing-libraries/documentation/libraries/radziplibrary/overview) 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();
                }
            }
        }
    }

```

## See Also

* [RadZipLibrary Overview](https://www.telerik.com/document-processing-libraries/documentation/libraries/radziplibrary/overview)
