I have a basic Windows 10 UWP app and use the following code to create a .zip file from a directory structure:
ZipFile.CreateFromDirectory("/inputpath", "/output.zip");
I noticed that the resulting .zip file does not have any entries for nested directories, thus unzipping on a Mac does not work.
Here is the directory structure that I want to include in the zip file:
./ziproot
./Data
Version.txt
What I get using the API ZipFile.CreateFromDirectory(...)
:
$ zipinfo output.zip
Archive: output.zip 279202 bytes 4 files
-rw---- 2.0 fat 1 b- defN 13-May-16 11:33 Data\Version.txt
When I use the Windows explorer to compress the test folder, I get the correct zip structure:
$ zipinfo zipwindows.zip
Archive: zipwindows.zip 279188 bytes 8 files
drwx--- 2.0 fat 0 b- stor 18-May-16 09:05 Data/
-rw---- 2.0 fat 1 t- stor 13-May-16 11:33 Data/Version.txt
Note the first entry for the Data
directory in the output above.
Is there a way to have the ZipFile
API include entries for directories without having to traverse the directory myself?