Given the following code:
using (var data = new MemoryStream(bytes))
using(var archive = new ZipArchive(data))
{
foreach (var entry in archive.Entries)
{
entry.FullName.Log();
}
...
The exception thrown is:
Illegal characters in path.
On the foreach
line.
How do I work out which the affected entry is? Whenever I try to access the entries it throws the exception. It appears that this specific archive is created from a Mac as it contains the _MACOSX
folder.
The stack trace:
[ArgumentException: Illegal characters in path.]
System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) +14351233
System.IO.Path.GetFileName(String path) +29
System.IO.Compression.ZipHelper.EndsWithDirChar(String test) +9
System.IO.Compression.ZipArchiveEntry.set_FullName(String value) +93
System.IO.Compression.ZipArchiveEntry..ctor(ZipArchive archive, ZipCentralDirectoryFileHeader cd) +228
System.IO.Compression.ZipArchive.ReadCentralDirectory() +172
System.IO.Compression.ZipArchive.get_Entries() +36