Folders
When I am adding files using a stream and I want to create a folder structure of files this way there is a problem with the folders. It will create the paths in the zip file for the files but I cant get it to actually create the folder entries in the zip. How can I create the folder entry without the file system? This is an issue with opening this with other systems.
ZipFile contains a method for that.
ZipEntry zd = zf.AddDirectoryByName(folder.Path);
Then zd will allow you to set folder parameters like time and so on. When saved it will contain the folder entries in the ZIP file as expected.
I know this is old but I couldn't find this info anywhere else. If you append a DirectorySeperatorChar to the filename it will create it as an empty directory entry.
...
using (var zip = new ZipOutputStream(fileStream))
{
if (!directoryName.EndsWith(Path.DirectorySeparatorChar.ToString()))
directoryName += Path.DirectorySeparatorChar.ToString();
var entry = zip.PutNextEntry(directoryName);
}
...
This issue can be closed.