DotNetZip checks if a folder exists in a zip file

I am trying to check if a folder exists in a zip file. The code is as follows:

//All entries refered too exists. //For files (Workes fine, returns true) var hello1 = zip.Any(entry => entry.FileName.Equals(@"Patients.xml")); var hello2 = zip.Any(entry => entry.FileName.Equals(@"Bookings.xml")); //For folders (Dosent work (returns false)) var result1 = zip.Any(entry => entry.FileName.Equals(@"PatientsF")); var result2 = zip.Any(entry => entry.FileName.Equals(@"U14")); 

I tried:

 entry.FileName.Contains(@"PatientsF")); 

And it works, but I want to get a folder with the exact name "PatientsF". With the code “Contains”, it will return true if the name has only “PatientsF”. How to fix it?

Any help would be appreciated. thanks in advance.

PS. If I'm somewhere unclear, or if you need more information, just explain what you need.

+4
source share
1 answer

Then expand what works to make sure you find the folder:

 entry.FileName.Contains("PatientsF/")); 

/ is a path separator, so it cannot be part of the file name.

+6
source

Source: https://habr.com/ru/post/1486622/


All Articles