0

I have a zip file (SomeZipFile.zip) and I created another zip file (by first extracting its contents and changing some text in sometextfile.txt and again compress).

Now the problem is entry.FullName with original zip returns paths with '/' and entry.FullName with copied zip file returns paths with '\'.

Can anyone please explain why is it so ? And how to compare paths irrespective of '/' or '\'

Thanks in advance

string CurrentArchive = @"SomeZipFileCopy.zip";
string requiredFile = @"SomeFolder/somefile.txt";
using (ZipArchive zip = ZipFile.OpenRead(CurrentArchive))
        {
            foreach (ZipArchiveEntry entry in zip.Entries)
            {

             if(entry.Equals(requiredFile))
                        Console.WriteLine(entry.FullName);

            }
        }
Tarun Kumar
  • 729
  • 1
  • 8
  • 16
  • When you compare two strings you may perform a Replace on the fly to normalize strings to be with the same case and same delimiters, and then compare them, for example: if(path1.Replace("\","/").ToLower()==path2.Replace("\","/").ToLower()) { ... } – SashaDu Feb 29 '16 at 08:32
  • And why does the path separator changes when I edit the zip file ??? – Tarun Kumar Feb 29 '16 at 08:47
  • @Tim Schmelter how can I edit the zip file so that path remains in same format? – Tarun Kumar Feb 29 '16 at 08:48

0 Answers0