4

I am using SevenZipSharp in order to compress files into a zip file. I am having 2 issues:

  1. When using CompressFiles miltiple times on the same destination file it does not append the files, but overwrites them.

  2. I would like the files to be added with out their whole path but can't seem to find how (I thought that PreserveDirectoryRoot = false would do the trick but it does not).

Does anyone have an idea?

egrunin
  • 24,650
  • 8
  • 50
  • 93
Maya
  • 141
  • 1
  • 4

1 Answers1

3

You need to use CompressionMode.Append after the first call. The default is CompressionMode.Create. Path can be dropped by altering DirectoryStructure.

Relevant source code is here.

    public sealed partial class SevenZipCompressor
#if UNMANAGED
        : SevenZipBase
#endif
    {
        /// Gets or sets the compression mode.
        /// </summary>
        public CompressionMode CompressionMode { get; set; }
        /// <summary>

        /// Gets or sets the value indicating whether to preserve the 
        ///   directory structure.
        /// </summary>
        public bool DirectoryStructure { get; set; }
    }
Steve Townsend
  • 53,498
  • 9
  • 91
  • 140
  • Thank you, the Directory structure works but I am still having a problem with the compression mode. After creating the zip I changed the mode to "Append" (comp.CompressionMode = SevenZip.CompressionMode.Append;). Though, when executing comp.CompressFiles for the second file it throws an exception: The given key was not present in the dictionary. I can't seem to understand why. – Maya Nov 11 '10 at 09:25