squid-box / SevenZipSharp

Fork of SevenZipSharp on CodePlex
GNU Lesser General Public License v3.0
267 stars 101 forks source link

Custom parameters not work #82

Closed deimspb closed 4 years ago

deimspb commented 4 years ago

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).

squid-box commented 4 years ago

0x80070057 means Invalid Arguments, I'm adding that to SevenZipSharp so it's more clear.

It look like you're trying to pass arguments for the -m parameter as parameters for 7zip, which isn't going to work.

I've never needed to use custom parameters, and from the 10 minutes I've spent reading up on them in the 7z documentation I can't provide you with the info you need. You'll need to figure that part out, but the error message you're getting is correct - there is no parameter for 7z that is mem.

deimspb commented 4 years ago

Hi! this custom parameters not for 7zip format. The are for Zip format. And 7zip dll work with it. I can create archive like this: 7z.exe a -tzip inFile outFile -mmt -mx9 -m0=PPMd:mem=128M:o=12 without any issues. some aaditional info about switches https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm

squid-box commented 4 years ago

Sorry, you are correct - I misunderstood how this works.

There is indeed something odd going on, a few of the parameters can be set this way, eg. in the CompressWithCustomParameters test. With your parameters, there's two errors:

  1. o gives an "Value does not fall within the expected range." message, for values that should be valid ([2-16] are specified to be valid in documentation).
  2. mem gives the "0x80070057 / E_INVALIDARG" using either of the suggested formats (eg. 128b, 128k, 128m, 27).

Both of these responses come from calling the SetProperties COM call to 7zip itself, so I can't easily determine where the problem lies - a likely guess is that SevenZipSharp isn't properly formatting the property values it's sending, but it will take me quite a while to work out what's going wrong.

I don't have much time to spend on this right now, so don't hold your breath on getting a quick fix for this.

squid-box commented 4 years ago

@deimspb : I've now released 1.2.258 with a fix for this, please try it when you have time and let me know if it works for you.

deimspb commented 4 years ago

@squid-box Thanks! Now it work for me without any errors!