squid-box / sevenzipsharp Goto Github PK
View Code? Open in Web Editor NEWThis project forked from tomap/sevenzipsharp
Fork of SevenZipSharp on CodePlex
License: GNU Lesser General Public License v3.0
This project forked from tomap/sevenzipsharp
Fork of SevenZipSharp on CodePlex
License: GNU Lesser General Public License v3.0
A exception is throw when we want to compress a large number of files (900 files - approximately 1Mo Each)
This is the stack trace :
at SevenZip.SevenZipBase.ThrowException(CallbackBase handler, Exception[] e) at SevenZip.SevenZipBase.CheckedExecute(Int32 hresult, String message, CallbackBase handler) at SevenZip.SevenZipCompressor.CompressStreamDictionary(IDictionary'2 streamDictionary, Stream archiveStream, String password) at SevenZip.SevenZipCompressor.CompressFileDictionary(IDictionary'2 fileDictionary, Stream archiveStream, String password) at SevenZip.SevenZipCompressor.CompressFileDictionary(IDictionary'2 fileDictionary, String archiveName, String password)
The working workaround is to do a compression call each 100 files.
Squid-Box.SevenZipSharp cannot extract some SFX archives or packed executables.
Ex) cloc-1.80.exe
First, thanks for your effort to maintain such a great library.
SevenZipSharp can extract files from 7zip's own SFX archive, but it cannot from third-party packed executable (e.g. installer, perl-runtime-packaged exectuable) which 7zip executable can extract.
7zip executable can open cloc binary's inside, and when I see its property 7zip detects its format as zip
while SevenZipSharp's internal file format detector results in InArchiveFormat.PE
. I performed some tests to find proper InArchiveFormat
for this file, but no single format was unable to extract that file, including InArchiveFormat.Zip
.
Currently, SevenZipSharp doesn't detect if the archive is the first volume of the multi-part archive. In the case of RAR archives, it is necessary cause all parts have the file extension of ".rar".
Currently, I determine it using the file name of the archive.
bool isVolume =
sevenZipExtractor.ArchiveProperties.Any(x =>
x.Name.Equals("IsVolume") && x.Value != null && x.Value.Equals(true));
if (isVolume)
{
var split = fileInfo.FullName.Split('.');
if (split.Length >= 3)
{
if (split[split.Length - 2].StartsWith("part"))
{
int.TryParse(split[split.Length - 2].Substring(4), out var volumeNumber);
if (volumeNumber != 1)
{
throw new Exception("Not the first volume of the archive.");
}
}
}
}
Is it possible add a feature using file headers (Volume Number under Main Archive Header) that can tell us if the current archive is the first volume or not?
I have been working with this for an updater for my mod manager and have noticed a few things.
finally
{
if (_archive != null)
{
_archive.Close();
}
((InStreamWrapper)_archiveStream).Dispose(); <-- This disposes the input stream.
_archiveStream = null;
_opened = false;
}
return true;
In my app (I have SevenZipSharp source) I changed the GetArchiveStream call in Check() to see if it's an emulationstreamproxy, and then checked if that source is a memorystream - if it is, don't close the stream. I will test this implementation to see if it's an working solution for other archive types. I try to get the test framework up and running and also add cases to test against memory-loading and extraction.
Using IDictionary as parameter to CompressStream|FileDictionary would give us the possbility to pass a SortedDictionary or ConcurrentDictionary directly to those methods.
I have a feature branch - #41 - with the proposed changes. Please review and let me know if you find it useful.
This seems like a bug to me but maybe it's just my lack of understanding how it should work. When I try to extract a single file the library seems to process the entire archive rather than just the single file. In my case I have an archive with one very large file and a bunch of little texts files (10). I try to extract one of the small text files and I have the "FileExtractionStarted" event fire 11 messages (one for each file in the archive) instead of just one total. That also means the "FileExtractionFinished" event fires 11 times and the "Extracting" event fires an excessive amount of times as well (once by percent update but for each file)!
Using 7zipFM I can extract the single file in a few milliseconds. Using this method it takes about 30 seconds. This becomes a huge problem when I use the same method to extract almost all the files. It then sends a "FileExtractionStarted" event for each file in the archive during EACH file actually being extracted!
I'm using the following code...
private void SevenZipExtractor_Extracting(object sender, ProgressEventArgs e)
{
//Only update every 20%
if (e.PercentDone % 20 == 0)
System.Diagnostics.Debug.WriteLine("SevenZipExtractor_Extracting -- " + e.PercentDone + "%");
}
private void SevenZipExtractor_FileExtractionFinished(object sender, FileInfoEventArgs e)
{
System.Diagnostics.Debug.WriteLine("SevenZipExtractor_FileExtractionFinished -- " + e.PercentDone + "% Filename:" + e.FileInfo.FileName);
}
private void SevenZipExtractor_FileExtractionStarted(object sender, FileInfoEventArgs e)
{
System.Diagnostics.Debug.WriteLine("SevenZipExtractor_FileExtractionStarted -- " + e.PercentDone + "% Filename:" + e.FileInfo.FileName);
}
private void DecompressThread(string archiveFilePath, string localPath)
{
//archiveFilePath is the path of the 7z archive
//localPath is the path of the newly extracted text file from the 7z archive
byte[] fileInBytes = File.ReadAllBytes(archiveFilePath);
using (MemoryStream inStream = new MemoryStream(fileInBytes))
{
using (SevenZipExtractor extractor = new SevenZipExtractor(inStream))
{
extractor.Extracting += SevenZipExtractor_Extracting;
extractor.FileExtractionStarted += SevenZipExtractor_FileExtractionStarted;
extractor.FileExtractionFinished += SevenZipExtractor_FileExtractionFinished;
using (FileStream file = new FileStream(localPath, FileMode.Create, FileAccess.Write))
{
//Extract a single file
// I know and have checked the extractor.ArchiveFileData[4] data
// to ensure it's the small text file I want to extract
extractor.ExtractFile(4, file);
}
extractor.Extracting -= SevenZipExtractor_Extracting;
extractor.FileExtractionStarted -= SevenZipExtractor_FileExtractionStarted;
extractor.FileExtractionFinished -= SevenZipExtractor_FileExtractionFinished;
}
}
}
Here are the results of the events I get from the Library (results_of_archive_extraction.txt). It seems to extract the single text file as I would expect but when doing so is VERY slow because it tries to process the entire file instead of just the one file.
I have a question opened on stackoverflow with more information. It refers to the SevenZipSharp.Interop NuGet that uses the same process your library uses. I get the same result with your library as well.
The unit tests could use some more formats to verify that they can be read/extracted. Have a look at what's already in TestData and what formats are supported in eg. InArchiveFormat.
I'd preferably see these test archives to be as small as possible.
The original project has some programs for testing SevenZipSharp, but these don't work very well since they're dependent on test files that are not in the project itself.
Tests that are estimated to be translated into NUnit tests:
Execution has failed due to an internal SevenZipSharp issue. 7zip version 18.5.0.0.
Hi
Any plans on targeting .Net standard 2.0?
Hi everyone,
I am having some issues to start using SevenZipSharp, may I ask you for help?
Otherwise, is there any tutorial to get started with SevenZipSharp?
I'd like to create a SFX file, but I am struggling to get started with SevenZipSharp. Here, my code:
var sfx = new SevenZipSfx();
SevenZipCompressor tmp = new SevenZipCompressor();
using (MemoryStream ms = new MemoryStream())
{
tmp.CompressDirectory(@"d:\Temp\", ms);
sfx.MakeSfx(ms, @"d:\Temp\test.exe");
}
When this code is ran, CompressDirectory method throws this exception:
{"Could not load file or assembly 'System.Security.Permissions, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The specified file could not be found.":"System.Security.Permissions, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"}
I did some googling and, as far as I understood, it seems that 7z.dlls are missing. Hence, I tried to add those reference and also use SeveZipSharp.Interop Nuget, but without success.
Can anyone point me in the right direction, please? Any help will be really appreciated.
Best regards,
Lore
P.S. I also tried to run tests from repository project, but without success. In fact, there is a "testhost.dll" missing error; the solutions provided on stackoverflow were not successful.
public void ExtractFiles(ExtractFileCallback extractFileCallback)
{
DisposedCheck();
InitArchiveFileData(false);
if (IsSolid)
{
// solid strategy
}
else
{
I commented the first branch, so that it always uses the implementation for non solid, but:
I've been trying to extract all files from some solid 7z files, it's fast at first but the further it gets the slower it gets, slows to almost stopped, takes 6 hours instead of 1 minute or so because of this.
It's doing a triangle.
ExtractFile(Index, Stream);
exhibits the same slowdown
I have a simple program that extracts entire archives of 7zip files. The archives contain video files so they tend to be large. My test archive is about 700MB and contains 119 video files. During testing, this simple loop:
for (var i = 0; i < extractor.ArchiveFileData.Count; i++)
{
extractor.ExtractFiles(BaseDirClass, extractor.ArchiveFileData[i].Index);
}
extracted 28 files and consistently hung on the 29th file. Memory utilization climbed to about 500MB (working set) before hang. Hang occurs at the same spot using 32-bit or 64-bit and also occurs when running from the command line or within the VS debugger. I tried ExtractALL
(i.e. extractor.ExtractArchive(BaseDirClass);) and got the same result at the same spot but the Working set shot up to about 2GB before the hang. Poked around a bit and determined that the problem appeared to be 7z.dll. I was using V19.0 of 7z.dll. Just for kicks, I tried 7za.dll and 7zxa.dll - same results. I then backpedaled a bit and tried V18.5 and got the same results. I gave it one more shot with V16.4 of 7z.dll and that worked just fine. The working set never got above 110MB.
Probably not much you can do about this but I thought I'd post this in case someone else runs into the same issue.
I've tried looking on this site for help but no one has the same issue. Can I get some help to fix this issue as its happening to both my Fallout 4 and Skyrim SE mods?
var extractor = new SevenZipExtractor(@"test.rar");
for (var i = 0; i < extractor.ArchiveFileData.Count; i++)
{
extractor.ExtractFiles("bb", extractor.ArchiveFileData[i].Index);
}
not responding at last file?
See unit test CompressFromStreamTest, where attempting to compress a FileStream into another FileStream will generate a SevenZipException ("The execution has failed due to the bug in the SevenZipSharp.").
See unit test ExtractDifferentFormatsTest, 7-Zip can extract "TestData\gzip.gz", but SevenZipSharp will throw SevenZipException ("The execution has failed due to the bug in the SevenZipSharp.").
As part of fixing #82, I've found that the "d" parameter (see documentation for uses) also doesn't work. The solution to #82 has not resolved this one, so I'm adding it here as a Known Issue.
The unit test SevenZipCompressorTests.CompressWithCustomParameters_BZip2
exposes this bug, but is marked as a warning for now.
This snippet shows the issue:
var compressor = new SevenZipCompressor
{
ArchiveFormat = OutArchiveFormat.Zip,
CompressionMethod = CompressionMethod.BZip2
};
compressor.CustomParameters.Add("d", "900000");
compressor.CompressFiles("path_to_archive, "path_to_file(s)_to_compress");
I would like to upgrade to the latest version of SevenZipSharp and the underlying 7z.dll
, but I am not sure which version of the DLL to use (or where to get a suitable version from).
7za.dll
and I don't really want support for "only 7zip archives".7z.dll
out of my local 7zip (application) installation, but that feels somehow "wrong" and makes me wonder whether there isn't an official, dedicated way to download the DLL for redistribution.can't use this parameters:
compressor.ArchiveFormat = OutArchiveFormat.Zip;
compressor.CompressionMethod = CompressionMethod.Ppmd;
compressor.CompressionLevel = CompressionLevel.Ultra;
compressor.Compressing += status;
compressor.CustomParameters.Add("mem", "128M");
compressor.CustomParameters.Add("o", "12");
Get this error: Execution has failed due to an internal SevenZipSharp issue (0x80070057).
See unit test ExtractDifferentFormatsTest, 7-Zip can extract "TestData\bzip2.bz2", but SevenZipSharp will throw SevenZipException ("The execution has failed due to the bug in the SevenZipSharp.").
I am trying to use the latest SevenZipSharp version from NuGet (currently 1.2.231).
My code looks like this:
SevenZipBase.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
using (var archive = new SevenZipExtractor(inputFile))
{
archive.ExtractArchive(outputPath);
}
The file 7z.dll
is present on the specified path; it is my local (flawlessly working) 7zip installation.
On the line starting with using
, the following exception is thrown:
SevenZip.SevenZipLibraryException: Can not load 7-zip library or internal COM error! Message: failed to load library from "C:\Program Files\7-Zip\7z.dll".
bei SevenZip.SevenZipLibraryManager.LoadLibrary(Object user, Enum format)
bei SevenZip.SevenZipExtractor.Init(String archiveFullName)
bei SevenZip.SevenZipExtractor..ctor(String archiveFullName)
Note that this also happens if I point to the very DLL file found in this repo (7z64.dll
). Also, the message is different from the one when the file really doesn't exist.
What am I missing?
Hello, @squid-box! I've notified huge performance degradation in case of a lot of small compressed files. Huge archive with real data (32gb uncompressed, 250k mostly small entries, something like compressed hard disk image) decompression is 4-12 times slower than with regular 7z.FM.exe, the main reason is excessive GC.Collect call in ArchiveExtractCallback.SetOperationResult (line 462) for each file. Test runs on such files show that ~70% of extraction time was spend in GC.Collect() call in our test case, our custom code allocates ~10kb of objects per second and 30-200 GC calls per second makes app suffer.
You can easily reproduce it with a lot of simple text files in one archive, I can send such if necessary.
Anyway it's weird that library collects garbage while it should be on application side, I've checked unzipping without GC calls and with different 7z archive content type and everything ok.
Probably reason of #46 is the same ArchiveUpdateCallback.SetOperationResult (line 709).
Thanks!
See Unit test CreateSfxArchiveTest.
Running the test runs into a problem:
System.ArgumentNullException : Value cannot be null.
Parameter name: src
at SevenZip.SevenZipSfx.WriteStream(Stream src, Stream dest) in D:\Git\GitHub\SevenZipSharp\SevenZip\SevenZipSfx.cs:line 362
at SevenZip.SevenZipSfx.MakeSfx(Stream archive, Dictionary`2 settings, Stream sfxStream) in D:\Git\GitHub\SevenZipSharp\SevenZip\SevenZipSfx.cs:line 432
at SevenZip.SevenZipSfx.MakeSfx(Stream archive, String sfxFileName) in D:\Git\GitHub\SevenZipSharp\SevenZip\SevenZipSfx.cs:line 383
at SevenZipTests.MiscellaneousTests.CreateSfxArchiveTest() in D:\Git\GitHub\SevenZipSharp\SevenZipTests\MiscellaneousTests.cs:line 80```
I work frequently with solid archive for distribution of mods for the Mass Effect series. Solid compression significantly reduces distribution sizes, so all mods are typically deployed using solid 7z, and the source files are uncompressed (game files support their own individual file compression, we do not distribute them this way to let 7z do more compression during transfer).
I am working to getting our per-file compression working, and it can take a stream to load a file in which is then fed to the compressor. I'm wondering if there's a way to fetch the output stream of a solid-archive extraction. I see this is possible, but not for solid archives. I understand how solid archives work (not the decompression of it though), so I'm wondering if this is possible. When I call extraction on the solid archive, I feed a list of indices to extract as sometimes I do not want the entire archive.
I can extract to disk and compress that instead, which is an alternative I could do. I would just like to reduce the disk I/O if possible by feeding the memory stream to my fileformat parsing which can then compress it as it extracts onto the disk.
Hi! After adding rar5 format support, you renamed rar to rar4 but forget to add in self extracting archives recognition block in FileChecker.CheckSignature. Please add "InArchiveFormat.Rar4," in FileChecker.cs row 174. Thanks!
Hi
I'm creating an Azure Function to unpack a password protected self-extracting file (.exe, but archive type is rar) from a FtpServer. I'm actually using the NuGet package shaman.SevenZipSharp (antiufo-fork), but it uses pretty much the same code (except for a few bug-fixes and .Net standard support).
I get an "Cannot access a closed file" when trying the following:
public IEnumerable<(Stream FileStream, string FileName)> PreprocessFtpFileStream(Stream fileStream, string orgFileName, BankSettings bankSettings)
{
var extractor = new SevenZipExtractor(fileStream, bankSettings.FilePassword);
var files = extractor.ArchiveFileData;
foreach (var entry in files)
{
var stream = new MemoryStream();
extractor.ExtractFile(entry.Index, stream); //Error happens here
yield return (stream, entry.FileName);
}
}
As far as I can tell from the source-code the error happens because extractor.ArchiveFileData disposes the underlying stream (calling InitArchiveData(true) which in turn calls GetArchiveInfo(true)).
So how do you extract all files in an archive and return data without writing them to disk first using ExtractArchive/ExtractFiles?
For example:
var arcFullName = @"C:\blablabla.7z";
var dirFullName = @"C:\Tmp\ForPacking"; //include file "test.txt"
var cmpr = new SevenZipCompressor();
cmpr.CompressionMode = File.Exists(arcFullName) ? CompressionMode.Append : CompressionMode.Create;
cmpr.PreserveDirectoryRoot = true;
cmpr.CompressDirectory(dirFullName, arcFullName);
1st run -> create archieve file "c:\blablabla.7z" with "ForPacking\test.txt"
2nd run -> archieve file "c:\blablabla.7z" consist of directory "ForPacking" with two files "test.txt" !?
What's wrong?
Ok, so I'm not sure if I'm a complete idiot or if this is a bug, but I was testing some compression out with a progress bar using the compression event and I discovered that deflate & deflate64 with the Zip OutArchiveFormat do not activate the compression event. (Using Ultra Level) It works with all the other compression formats and methods are far as I can tell.
Code for event:
sevenZipCompressor.Compressing += (sender, args) =>
{
Console.WriteLine("Should be activated."); //Isn't activated at all
progress.Report(args.PercentDone);
};
I'm using the SevenZipCompressor.CompressDirectory(); method.
EDIT:
Ok, so it appears that it works while compressing files (SevenZipCompressor.CompressFiles();), but not with the compress directory method.
I am not sure if this is an issue with sevenzipsharp or the 7z.dll (I am using one from 7z 19.00), but when I subscribe to the Compressing event, when I inspect the argument's PercentDone value, it seems to be wildly off. It will go from 0-100 very quickly (for a 2GB source directory I am compressing), in which I believe it is filling buffers. After this reaches 100%, I get no more progress notifications until the archive job is complete - which can take several minutes.
When I use 7zip gui to compress this archive, I see correct progress, so I am wondering if maybe the compression callback is binded to the wrong interface to the dll? It shows bytes written going all the way up to the 2GB of data, but it seems more like that's what's read and not what's actually been processed, as my process sits at 14GB of memory for almost 3 minutes until the archive is done being generated.
My code to generate an archive:
var compressor = new SevenZip.SevenZipCompressor();
compressor.CompressionLevel = CompressionLevel.Ultra;
//compressor.CustomParameters.Add("s", "on"); //can't figure out how to make it do solid archives
compressor.Compressing += (a, b) =>
{
Debug.WriteLine(b.PercentDone);
mainWindow.UpdateBusyProgressBarCallback(new ProgressBarUpdate(ProgressBarUpdate.UpdateTypes.SET_VALUE, (int)b.PercentDone));
};
compressor.FileCompressionStarted += (a, b) => { Debug.WriteLine(b.FileName); };
compressor.CompressFileDictionary(archiveMapping, archivePath);
compressor.CompressionMode = CompressionMode.Append;
compressor.CompressionLevel = CompressionLevel.None;
compressor.CompressFiles(archivePath, new string[]
{
Path.Combine(ModBeingDeployed.ModPath, "moddesc.ini")
});
Utilities.HighlightInExplorer(archivePath);
After doing some investigation, it seems the process for archive compression works like this;
It is step 2 that would be most useful. I am looking into seeing how it is done in 7z UI, maybe it is exposed via some sort of interface.
Hello, can I extract files changing filenames?
For example archive struct is:
root/folder1/file.txt
I want at the end:
my folder/file.txt
As discovered while investigating #25, it seems that
don't work when SevenZipExtractor is created with a FileStream instead of a file path.
I have more than 1 million small files in the test directory.
use:
compressor.CompressDirectory(fileOrDirectoryName, zipPath, password);
This situation will cause the program to become unresponsive。
I am trying to compress an archive and I have been using the Ultra compression setting. I am porting code from an old program that used 7z on the command line with a -md=256m (which is 2^28). mx9 (ultra) is only 64MB dictionary, which when compressing my archive is the difference between a 29MB (256MB dictionary) archive and a 59MB archive (64MB dictionary)
I have tried compressor.CustomParameters.Add("d", "28") but I get an invalid argument exception when the properties are set to the 7z binded dll. The d parameter is converted to an int so I can't use 256m for example. I can't find any tests or anything in the code for this project on how to use a custom dictionary size, which is really important for the kind of work that I am doing.
Anyone know how to do that? (I am using 7z LZMA).
My issue was that myx was not implemented. After doing some debugging it is due to the parameter binding not being cast to int before binding (instead binding as string).
https://github.com/squid-box/SevenZipSharp/blob/dev/SevenZip/SevenZipCompressor.cs#L313
On this line if you add a || pair.Key == "yx" on the end it fixes it. I might put a in a PR when I have time (I have a custom version of this library in my project so it takes more effort to put a PR back).
Once casted to an integer, yx works.
Hi,
I am using sevenzipsharp and I have a lot of archives that are msi, rar, iso and more formats that ExtractArchive decided it is TAR and because of that failed to extract them.
The archives can be extracted via the 7zip gui.
So I am sure the archives are OK.
Edited : some msi and rar extracted OK via the ExtractArchive but lot of Tham are failing.
var zipStream = new FileStream("c:\\backup\\file.zip", FileMode.Open);
SevenZip.SevenZipBase.SetLibraryPath("x86\\7z.dll");
var z = new SevenZip.SevenZipExtractor(zipStream, "pass");
z.BeginExtractArchive("c:\\tmp\\test_ext");
.net 4.5.2
The specified stream can not seek or read.
Имя параметра: stream
Server stack trace:
в SevenZip.SevenZipExtractor.ValidateStream(Stream stream) в C:\projects\SevenZipSharp\SevenZip\SevenZipExtractor.cs:строка 691
в SevenZip.SevenZipExtractor.Init(Stream stream) в C:\projects\SevenZipSharp\SevenZip\SevenZipExtractor.cs:строка 100
в SevenZip.SevenZipExtractor.RecreateInstanceIfNeeded() в C:\projects\SevenZipSharp\SevenZip\SevenZipExtractorAsynchronous.cs:строка 36
в SevenZip.SevenZipExtractor.DisposedCheck() в C:\projects\SevenZipSharp\SevenZip\SevenZipExtractor.cs:строка 352
в SevenZip.SevenZipExtractor.ExtractArchive(String directory) в C:\projects\SevenZipSharp\SevenZip\SevenZipExtractor.cs:строка 1270
There are at least these three nuget packages references in the project
System.Configuration.ConfigurationManager
System.Security.Cryptography.ProtectedData
System.Security.Permissions
For just to compress a file I need to make a reference to System.Configuration.ConfigurationManager
in my .net std. 2.0 project.
System.Security.Cryptography.ProtectedData
seem to have two dll's by the same name, one is located in a subfolder(\runtimes\win\lib\netstandard2.0)....do I need both? It a little messy to distribute.
I expected I only had to make a reference to SevenZipSharp.dll
in my own project.
If it cannot be solved be changing the code then what about adding it (or all three/four) as dependencies in the Nuget package. Perhaps even add 7z.dll as a dependency.
Not that I like to use Nuget myself, but at least I can see which additional dll's I need to get into my project.
Would you consider licensing under LGPL also? GPL 3 is a bit more restrictive than my company is willing to allow.
Nuget package: Squid-Box.SevenZipSharp 1.1.106
I've got password protected ZIP archive without encrypted filenames inside. When I try to unpack such archive without any password, it extracts zero sized files to the output folder. No exception is raised.
var extractor = new SevenZipExtractor(path_to_archive)
extractor.Check() returns true which is not correct
var extractor2 = new SevenZipExtractor(path_to_archive, "correctpassword");
extractor2.Check() also returns true which is correct this time
Is there any way how to prevent such behavior or some kind of workaround? The only workaround I come up with is to try to extract the first file in archive and check its size...
Thank you
David
To quote AppVeyor:
Error 422 sending to coveralls.io: Unprocessable Entity
- Error code 422 indicate a problem with your token. Use the --debug option for more details.
license file states GPL 2.1, but many other parts of the project mentions 3.
Figure out which one to use and ensure it's the same throughout the project.
SevenZip.SevenZipArchiveException: 'Invalid archive: open/read error! Is it encrypted and a wrong password was provided?
If your archive is an exotic one, it is possible that SevenZipSharp has no signature for its format and thus decided it is TAR by mistake.'
This error has been consistently reproduced in 3 different .zip archives. Not sure what to make of this. The files are not password protected, not corrupted and are not locked by another process.
Now that SevenZipSharp support .Net Std. will it then be running in .Core on Linux too?
I'm seeing an issue with the 7zip.dll...are there an equivalent Linux library that can be used?
I want to rename and/or delete files from a 7z archive
When I use this code (i.e. no password) it works. It creates the zip. I can open it in 7zip and extract files, etc in the archive created in the first step. Also the first file is renamed and the second removed.
Dim Compressor As New SevenZip.SevenZipCompressor
Compressor.EncryptHeaders = True
Compressor.CompressFiles("d:\temp\test.7z", {"D:\Temp\svg.txt", "D:\Temp\tmp.txt"})
Dim NewList = New Dictionary(Of Integer, String)
NewList.Add(0, "newsvg.txt")
NewList.Add(1, Nothing)
Compressor.ModifyArchive("d:\temp\test.7z", NewList)
But this code does not - throws exception complaining about wrong password. As with above, the archive created is fine -- just that ModifyArchive has trouble with it.
Dim Compressor As New SevenZip.SevenZipCompressor
Compressor.EncryptHeaders = True
Compressor.CompressFilesEncrypted("d:\temp\test.7z", "password", {"D:\Temp\svg.txt", "D:\Temp\tmp.txt"})
Dim NewList = New Dictionary(Of Integer, String)
NewList.Add(0, "newsvg.txt")
NewList.Add(1, Nothing)
Compressor.ModifyArchive("d:\temp\test.7z", NewList, "password")
Thanks for the great library.
I am having some problems with it. I tried to read .tar.gz and .tar.bz2 files but it comes with wrong data. It shows only 1 file in the archive "[no name]".
You can download the example file from here.
I also tried the same file with SevenZipLib and it works fine.
Hello, this can be reproduced in ExtractionFromStreamTest():
//var bytes = File.ReadAllBytes(@"TestData\multiple_files.7z");
var bytes = File.ReadAllBytes(@"TestData\zip.zip");
Dear Community,
I just recognized that the version 1.0.19.0 simply hangs at SevenZipExtractor.ExtractArchive(), when the path is too long, there is no exception, the function just never returns.
In a former version there was a PathToLongException.
Has anyone an idea how to prevent hanging?
Thanks and best regards,
Jürgen
How can I cancel a single file compression after it had started?
In the Compressing event there is no way to cancel it.
I am trying to store the 7z.dll(s) in my resources. I used to use the ionic.dll library and was able to unzip files from resources in memory, but I am having a hard time figuring out how to do the same with a 7z files. I tried
Dim currentAssembly = Reflection.Assembly.GetEntryAssembly()
Dim currentDirectory = New FileInfo(currentAssembly.Location).DirectoryName.ToString
Dim path As String = currentDirectory + "My.Resources\" And If(IntPtr.Size = 4, "7z86.dll", "7z64.dll")
Using extractor = New SevenZipExtractor("My.Resources.Source.7z", "Pass1")
For i = 0 To extractor.ArchiveFileData.Count - 1
If extractor.ArchiveFileData(i).tostring.contains(Desired_File_Name) then
extractor.ExtractFiles(OutputDirectory, extractor.ArchiveFileData(i).Index)
'unzip file in memory and load to richtextbox
'Richtext1.LoadFile(msss, RichTextBoxStreamType.RichText)
Exit For
End If
Next
End Using
I know the code above doesn't work, I have been trying to go through the tests to make work with no success. I am trying to access the encrypted file, locate the file based on its name, unzip the file in memory and load it to a richtextbox. Do you think that is possible with this library?
Thanks in advance,
Beho
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.