Extract a ZIP file programmatically by DotNetZip library?

前端 未结 3 409
無奈伤痛
無奈伤痛 2020-12-08 19:50

I have a function that get a ZIP file and extract it to a directory (I use DotNetZip library.)

public void ExtractFileToDirectory(string zipFileName, string          


        
3条回答
  •  無奈伤痛
    2020-12-08 20:17

    You can also use LINQ to select which entries you want to extract. For example:

    using (var zip = ZipFile.Read(ArchiveToRead))
    {
        var selection = from e in zip.Entries
            where System.IO.Path.GetFileName(e.FileName).StartsWith("C")
            select e;
    
        foreach (var e in selection)
            e.Extract(extractDir);
    }
    

    Of course you can use whatever query criteria you want in the where clause.

提交回复
热议问题