Get all file names when unzip file

Binumon George 161 Reputation points

Hi All,
I am zipping one folder containing 10 files like abc.txt, pqr.docx,xyz.txt, etc using c#. Now I want to unzip that zip file. But when I Unzip I want to get all files' names in a string with a comma-separated value. How it's possible using c#?

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,356 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Petrus 【KIM】 456 Reputation points
    public string GetFilenamesInZip(string sZipFileName)
        string sFileNames = string.Empty;
        using (ZipArchive oArchive = ZipFile.OpenRead(sZipFileName))
            foreach (var vEntryItem in oArchive.Entries)
                sFileNames += (vEntryItem + ",");
        if (sFileNames != string.Empty)
            sFileNames = sFileNames.Substring(0, sFileNames.Length - 1);
        return sFileNames;
    0 comments No comments