0

I am creating zips using System.IO.Compression.ZipFile.CreateFromDirectory(startPath,zipPath). All is well on Windows afterwards - they unzip just fine. If I unzip these on MacOS (Mojave), the folder-structure is lost. As an example, I have ziptest.zip with:

A/B/C/file1.txt
A/B/C/file1.txt

on MacOS (using context-menu's "Open with...Archive utility (Standard)", I get a folder ziptest that contains the files A\B\C\file1.txt and A\B\C\file2.txt. Looks as if the directory-separator is the problem. But I can't believe MS would have been so blind to miss this issue. (Although it seems common - I tried various cmdline-zippers and only SFK did it right...) Is there an easy solution or is it truly a MS-bug? (And how can we get it fixed...?)

Update to answer Panagiotis' question: I'm on release 528040 which corresponds to 4.8. (Unfortunately it's no longer as easy as doing System.Environment.Version, we're back to checking the registry...)

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
MBaas
  • 7,248
  • 6
  • 44
  • 61
  • Which .NET version are you using to compress the data? [This possibly duplicate question](https://stackoverflow.com/questions/27289115/system-io-compression-zipfile-net-4-5-output-zip-in-not-suitable-for-linux-mac) explains that the forward slash is used since 4.6.1. – Panagiotis Kanavos Oct 22 '19 at 10:08
  • Good question, thanks! Should have mentioned that - so I updated the question... – MBaas Oct 22 '19 at 10:27
  • So it's *not* .NET Core as the tag says – Panagiotis Kanavos Oct 22 '19 at 10:27
  • Right - I'll have to check why it isn't. But still . 4.8>4.6.1... – MBaas Oct 22 '19 at 10:31
  • 2
    No repro. Calling `ZipFile.CreateFromDirectory(@"c:\somesource",@"c:\somefolder\target.zip");` produces a zip that rebuilds any subfolders found in `somesource` when opened with Archive Utility. You'll have to post a minimal example that actually reproduces the problem. Tried on Catalina – Panagiotis Kanavos Oct 22 '19 at 10:38
  • Opps. Thanks - I'll see if I can come up with a repro. I thought it was a general problem... – MBaas Oct 22 '19 at 10:46

1 Answers1

0

Thanks, Panagiotis Kanavos for looking into this - I tried a repro in C# and that worked, too - so it must be a fault in the development-environment I'm using. Will report to the manufacturer. Glad it wasn't MS' fault.

MBaas
  • 7,248
  • 6
  • 44
  • 61