SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Zip Folder with the root folder included

Last post 07-18-2007 9:42 PM by JohnReilly. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-18-2007 3:33 AM

    Zip Folder with the root folder included

    Hi,

    The example :

    - rootfolder1

        - subfolder1.1

            - subfolder1.1.1

                - filename1.1.1.1

            - filename1.1.2

        - subfolder1.2

            - subfolder1.2.1

            - filename1.2.2

        - filename1.3

        - filename1.4

        - filename1.5 

    I need to zip subfolder1.1 folder, filename1.3, and filename1.5 into a zip file, while still preserving the folder structure of subfolder1.1.

    Right now, what I can achieve is having filename1.3 and filename 1.5 and the content of subfolder1.1, I was not able to have the subfolder1.1 and then the content of subfolder1.1

    My current code logic is

    1. Create the zip file

    2. Process the folders using FastZip : fz.CreateZip(fs, "rootfolder1\\subfolder1.1", true, string.Empty, string.Empty); 

    3. Include the filename1.3 and filename 1.5 using ZipFile : zipFile.Add(new FileDataSource(filename), Path.GetFileName(filename));

    Based on the logic no. 2 : i know it will grab only the content, but i require the subfolder1.1 folder also before the content.

    Is there any workaround for this?

    Thanks. 

  • 07-18-2007 9:42 PM In reply to

    Re: Zip Folder with the root folder included

    Hi,

    FastZip has a property called NameTransform (INameTransform) which controls how the entry names are generated.  If you derive a class from ZipNameTransform or create your own and set the property to an instance of your new class you can tweak this to do whatever you wish.

            string TransformFile(string name)

    is what you wish to tweak.    The result of this is what you will see in the zip file as the entry including any path.
     

    hth, -jr-

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.