How to check whether file exists in zip file using dotnetzip

后端 未结 2 520
傲寒
傲寒 2021-01-13 07:09

I am creating zip using dotnetzip library.

But I don\'t know how to check if a file exists in the zip. If the file exists then I will update the file with path.

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 07:53

    How to check whether file exists in zip file?

    Just use LINQ Any, assume you have input zip file input.zip, to check whether input.zip contains input.txt:

     var zipFile = ZipFile.Read(@"C:\input.zip");
     var result = zipFile.Any(entry => entry.FileName.EndsWith("input.txt"));
    

提交回复
热议问题