Zip directory

Posted by: kisar on 7 June 2018, 6:23 pm EST

    • Post Options:
    • Link

    Posted 7 June 2018, 6:23 pm EST

    Hi, I’m using the c1.C1Zip library

    I want to zip a folder, but I need that the folder too is in the zip file.

    When I use “addfolder” it add the content inside the directory,

    but I loose the main directory.

    Can you say how can I do.

    Example : if I zip this directory1 I what to find it in the zip and not only file1 and file2.

    
    directory1	\file1
    			\file2
    
    

    thank you

  • Posted 10 June 2018, 10:22 pm EST

    Hi!

    It seems that you are trying to add a zipped folder to another zipped folder. For this, use Entries.Add (http://help.grapecity.com/componentone/NetHelp/c1zip/webframe.html#C1.C1Zip.4~C1.C1Zip.C1ZipEntryCollection~Add.html) method instead of AddFolder method.

    For demonstration purpose, you can find C1Zipper sample (refer AddFileList function in Form1.cs file) at this location :

    \Documents\ComponentOne Samples\WinForms\C1Zip\CS\C1Zipper

    The code should look something like this :

    // add files
    foreach (string file in files)
    {
             // add the file
             try
             {
                      _zipFile.Entries.Add(file, pathLevels);
                      Application.DoEvents();
             }
             catch (Exception x)
             {
                     //Exception handling code here...
             }
    }
    

    Best regards,

    Meenakshi

  • Posted 13 June 2018, 4:10 am EST

    Hi, no maybe i did not explain good,

    If we refer to the directory above

    and i user zip.AddDirectory(path_mydirectory1)

    in the zip file i will find : file1 and file2.

    I would like to have the main directory1 as first entry.

    Thanx

  • Posted 14 June 2018, 3:40 pm EST

    Hi!

    So you are willing to add this zipped folder (containing file1 and file2) into directory1. In this case, I would like to inform you that you can perform operations such as add, delete within a main parent zipped folder only.

    There is no workaround to add zipped file(s) and folder(s) into a simple folder using C1ZipFile.

    Do let me know if there is anything with which I can help you.

    Best regards,

    Meenakshi

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels