Search code examples
c#tddzip

Count number of files in a Zip File with c#


I'm generating some .csv files and I need to compress this inside a Zip File. Ok, I have a framework to do this and probably everything will be fine.

But! As TDD says I just can write code, after I have some tests!

My first test sound simple, but I'm having some problems reading the Zip file, anyone know a simple way to count the number of files in my zip file?


Solution

  • You seem to be looking for something like DotNetZip.

    int count;
    using (ZipFile zip = ZipFile.Read(path))
        count = zip.Count;