Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DotNetZip check if folder exists in zip file

Tags:

c#

dotnetzip

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

//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 have tryed with:

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

And that works, but i want to get the folder with the exact name "PatientsF". With the code "Contains" it would return true if the name just have "PatientsF". How should i fix this?

Any help will be appreciated. thanks in advance.

PS. If i'm unclear somewhere, or if you need more information then just explain what's needed.

like image 451
MasterXD Avatar asked Mar 24 '23 13:03

MasterXD


1 Answers

Then expand on what does work to make it sure to find a folder:

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

The / is a path delimiter, so it cannot be part of a filename.

like image 119
DonBoitnott Avatar answered Apr 11 '23 07:04

DonBoitnott