luuksommers / SevenZipSharp.Interop

Other
36 stars 10 forks source link

Not working compressing to a stream? #20

Open Mrgaton opened 5 months ago

Mrgaton commented 5 months ago

My code

     using (FileStream fs = File.Open(outFile,FileMode.OpenOrCreate))
     {
         foreach (var file in args.Where(File.Exists))
         {
             compressor.CompressFiles(fs, new string[] { file });
             compressor.CompressionMode = SevenZip.CompressionMode.Append;
         }

         foreach (var dir in args.Where(Directory.Exists))
         {
             compressor.CompressDirectory(dir, fs);
             compressor.CompressionMode = SevenZip.CompressionMode.Append;
         }
     }

the exception

nhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'SevenZipCompressor [1201132722]' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at SevenZip.SevenZipLibraryManager.InArchive(InArchiveFormat format, Object user)
   at SevenZip.SevenZipCompressor.SetCompressionProperties()
   at SevenZip.SevenZipCompressor.GetArchiveUpdateCallback(FileInfo[] files, Int32 rootLength, String password)
   at SevenZip.SevenZipCompressor.CompressFilesEncrypted(Stream archiveStream, Int32 commonRootLength, String password, String[] fileFullNames)
   at SevenZip.SevenZipCompressor.CompressFilesEncrypted(Stream archiveStream, String password, String[] fileFullNames)
   at SevenZip.SevenZipCompressor.CompressFiles(Stream archiveStream, String[] fileFullNames)
Mrgaton commented 5 months ago

I want to compress to a memory stream so i dont have to touch disk but is not workin

Mrgaton commented 5 months ago

If you compress a file array then if you save the stream data to a file the file mises the 7z header and doesnt work to open it with 7zip