Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Storing Relative Paths using preservePaths property?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20357 |

    Hello,

    I am trying to zip specific contents of a folder while preserving the relative path of the files.  Here is an example of what I mean:

    I have the following folder structure:

    \a.txt

    \b.txt

    \folder\c.txt

    \folder\innerfolder\d.txt

    \folder\innerfolder\e.txt

    and I am attempting to zip only files a c and d.  When using the preservePaths property, the full path of the file is stored (e:\blah\blah\blah\folder\innerfolder\) instead of the relative path (\folder\innerfolder)

     Btw, the files to be zipped are determined by a manifest xml file, so a simple filter won’t work.

     

    Is there any way to select specific files to zip while preserving their relative paths?

     

    Thanks,

    Chuck

    Imported from legacy forums. Posted by Charles (had 951 views)

    User (Old forums)
    Member
    Post count: 23064

    I came up with a pretty clean solution:

     

    AbstractFolder aFolder = new MemoryFolder();

    string pathname = GetLastDirectoryComponent(relativePath);

    if(!isRoot) aFolder = z.CreateFolder(pathname);

    foreach (string file in filenames)

    {

    string fileName = Path.GetFileName(file);

    if (manifestFilesArray.Contains(fileName.ToUpper()))

    {

    AbstractFile aFile = new DiskFile(CombineRelativePathAndFileName(relativePath, fileName));

    if (!isRoot) aFile.CopyTo(aFolder, true);

    else aFile.CopyTo(z, true);

    }

    }

    Imported from legacy forums. Posted by Charles (had 1249 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.