Febertson
Febertson

Reputation: 474

Keeping specific directories when zipping files, using SevenZipSharp

In my Application im using the SevenZipSharp library and I want to compress an Array of Files. Each of my Files is in the same Directory, for example:

When I call the Method CompressFiles, it cuts my Directory from the Compression while I want to keep the "xyz" Path of my Files. Is there a way to achieve this? Or do I have to use the CompressDirectory Method for this?

Example:

var myCompressor = new SevenZipCompressor
{
    ArchiveFormat = OutArchiveFormat.SevenZip,
    CompressionMethod = CompressionMethod.Lzma2,
    PreserveDirectoryRoot = true,
    DirectoryStructure = true,
    IncludeEmptyDirectories = true
};
string[] files = new string[2] { "abc/xyz/file1.txt", "abc/xyz/file2.txt" }
myCompressor.CompressFiles("somePath", files);

Result:

  • Archive
    • file1.txt
    • file2.txt

What I want:

  • Archive
    • xyz
      • file1.txt
      • file2.txt

Upvotes: 0

Views: 105

Answers (0)

Related Questions