Welcome to the Xceed Community | Help
Community Search  
More Search Options

Exceed Zip library for .NET issue with preserving path of folders

Sort Posts: Previous Next
  •  03-02-2010, 7:56 AM Post no. 25975

    Exceed Zip library for .NET issue with preserving path of folders

    Hello ,
     
    I have two files located in folder structure as follows
    1) C:\Abc\Def\F1.Doc
    2) C:\Abc\Hij\F2.Doc

    I want to create ZIp file which will contain both F1.doc and F2.doc, by preseving their folder structure and base path as "C:\Abc". i.e. when I unzip my file at any location, then it will create F1.Doc in Def folder and F2.Doc in Hij folder and does not create "C:\Abc".

    This we used to do in earlier version of xCeed by giving below property
    XceedZip1.BasePath = "C:\Abc"
    XceedZip1.PreservePaths = True

    I am using Xceed Zip library for .NET now. Can any body provide me sample code in .NET for the same or Property names?

  •  03-04-2010, 2:03 PM Post no. 26003 in reply to 25975

    Re: Exceed Zip library for .NET issue with preserving path of folders

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Xceed.Zip;
    using Xceed.FileSystem;

    namespace _25975_PreservZIPPath
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                ZipArchive myZip = new ZipArchive(new DiskFile(@"D:\ZipTest\AllFiles.zip"));

                myZip.BeginUpdate();

                foreach (DiskFolder df in new DiskFolder(@"D:\ZipTest\").GetFolders(false))
                {
                    df.CopyTo(myZip, true);
                }

                myZip.EndUpdate();
            }
        }
    }

    In AllFiles.zip, I have exactly

    1) \Abc\Def\F1.Doc
    2) \Abc\Hij\F2.Doc

    since I have that folder structure + two Word documents.

    Best regards,


    Ghislain
    Technical Support and software developer
    Xceed Software Inc.
    Knowledge Base : http://xceed.com/kb/
    Update Center : http://xceed.com/updates/
    Documentation Center : http://xceed.com/doc/
    For everything else, there is Google
    Filed under: , , ,
  •  03-17-2010, 12:50 PM Post no. 26165 in reply to 26003

    Re: Exceed Zip library for .NET issue with preserving path of folders

    I have the similar issue. How to preserve the directory hierarchy, just by taking the seperate files from different directories. ie a:\b\c\d.txt and a:\b\e\f.txt

    and when i unzip, it should have c\d.txt and e\f.txt  ie rather than using entire folder contents, I need to deal with single files in a directory?

     

     

  •  03-18-2010, 12:02 AM Post no. 26175 in reply to 26165

    Re: Exceed Zip library for .NET issue with preserving path of folders

    Hi Naresh,

    for your particuliar situation, assuming you have a C: drive with a writable \temp folder, the simplest answer is:

    namespace _26165_PreservZIPPath
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                ZipArchive myZip = new ZipArchive(new DiskFile(@"C:\Temp\AllMyFiles.zip"));

                myZip.BeginUpdate();

                foreach (DiskFolder df in new DiskFolder(@"A:\B\").GetFolders(false))
                {
                    df.CopyTo(myZip, true);
                }

                myZip.EndUpdate();
            }
        }
    }

    Of course, for more flexibility, you could get the user input, (i.e. the starting point of the hyerarchy of the folders to be zipped), in a textbox, and the destination in another textbox, minimally.  And this would have to be activated by a click of a button, of course, splitting the code above so you get the InitiazeComponent() out of event handler code., There are tons of ways to improve the basic solution.  

    Best regards


    Ghislain
    Technical Support and software developer
    Xceed Software Inc.
    Knowledge Base : http://xceed.com/kb/
    Update Center : http://xceed.com/updates/
    Documentation Center : http://xceed.com/doc/
    For everything else, there is Google
    Filed under: , ,
  •  07-21-2010, 10:13 AM Post no. 27637 in reply to 26175

    Re: Exceed Zip library for .NET issue with preserving path of folders

    I have a similar problem where I want to retain the folder structure, but only want to zip certain files in each folder (rather than all the files).  The CopyTo method doesn't allow for a filter.  How can I zip certain files and still retain the folder structure?
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.