Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top