Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working compressing to a stream? #20

Open
Mrgaton opened this issue May 29, 2024 · 2 comments
Open

Not working compressing to a stream? #20

Mrgaton opened this issue May 29, 2024 · 2 comments

Comments

@Mrgaton
Copy link

Mrgaton commented May 29, 2024

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
Copy link
Author

Mrgaton commented May 29, 2024

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

@Mrgaton
Copy link
Author

Mrgaton commented May 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant