Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pack empty directory with SharpZipLib

Tags:

c#

zip

I want to pack to zip some folder using SharpZipLib. Example stucture

directory1:
    directory2:
         file1
    file2
    directory3:
        directory4:

When I pack it using c# code from here:

http://wiki.sharpdevelop.net/SharpZipLib-Zip-Samples.ashx#Create_a_Zip_with_full_control_over_contents_0

I get zip archives without directory3 and directory4.

My question is how can I pack to get archives with directory3 and directory4.

like image 289
nirmus Avatar asked Feb 21 '23 11:02

nirmus


1 Answers

 FastZip fastZip = new FastZip();

 fastZip.CreateEmptyDirectories = true;
 // Include all files by recursing through the directory structure
 bool recurse = true; 
 // Dont filter any files at all 
 string filter = null;
 fastZip.CreateZip("fileName.zip", @"C:\SourceDirectory", recurse, filter);

one caveat is that it can't handle UTF-8 file names.

Here is the link to the documentation wiki:

http://wiki.sharpdevelop.net/SharpZipLib_FastZip.ashx

like image 150
Eric H Avatar answered Mar 01 '23 23:03

Eric H