Create normal zip file programmatically

后端 未结 11 859
野的像风
野的像风 2020-12-05 00:06

I have seen many tutorials on how to compress a single file in c#. But I need to be able to create a normal *.zip file out of more than just one file. Is there anything in .

11条回答
  •  情深已故
    2020-12-05 00:28

    My 2 cents:

        using (ZipArchive archive = ZipFile.Open(zFile, ZipArchiveMode.Create))
        {
            foreach (var fPath in filePaths)
            {
                archive.CreateEntryFromFile(fPath,Path.GetFileName(fPath));
            }
        }
    

    So Zip files could be created directly from files/dirs.

提交回复
热议问题