Search code examples
c#uwpc#-ziparchive

Change sort order for a System.IO.Compression.ZipArchive


For some reason ZipArchive sorts by date modified. I need it to sort by name. I tried sorting it as one would sort any other collection of objects yet it makes no difference, it still sorts by date modified.


// I tried this
var orderedArchive = archive.Entries.OrderBy(x => x.Name);

// and this
foreach (var entry in archive.Entries.OrderBy(x=>x.Name))
...

The results are like I did no sorting.


Solution

  • My solution was:

    var orderedEntries = 
                    from entry in archive.Entries
                    orderby entry.Name
                    select entry;