Create ZIP structure in memory

Hi

I need to create simple ZIP Archive but not flat with desired directories structure. I do not have file system all data is in memory. How can I create ZIP archive with specific structure For example like follow

[A]
[B]
file1.data
file2.data
[C]
file3.data
[D]

It seems like I suppose to use
archive.CreateEntry with the name but gives me an error on passing null as the Stream argument
Thank you!

Hello @yuriy.mazurchuk, you need to set names of entries respecting the nesting. Here is a sample:

using (Archive archive = new Archive())
{  
    archive.CreateEntry("outer\\data.bin", datasource1);
    archive.CreateEntry("outer\\subfolder1\\data.bin", datasource2);
    archive.CreateEntry("outer\\subfolder2\\data.bin", datasource3);
    archive.CreateEntry("outer2\\subfolder1\\data.bin", datasource4);
    archive.CreateEntry("outer2\\subfolder1\\data2.bin",datasource5);
    archive.Save("hierarchy.zip");
}

Generally, you do not need entries for directories.

Blockquote Generally, you do not need entries for directories.

How can I create empty directory in tar archive?

Use following code sample for tar archive

using (TarArchive archive = new TarArchive())
{
     archive.CreateEntry("first.bin", "data.bin"); // regular file entry

     DirectoryInfo di = new DirectoryInfo("emptyfolder");
     archive.CreateEntry("emptyfolder", Stream.Null, di); // empty directory entry

     archive.Save("result.tar");
}