如何使用Squid-Box压缩和解压C#上的文件。SevenZipSharp执行失败错误
我最近尝试过使用NuGet压缩和解压文件 但是我不能压缩它们,错误可能来自dll库。我试过下载32位和64位的7zip,使用了这两个.dll,但错误是一样的,我想不出有什么办法如何使用Squid-Box压缩和解压C#上的文件。SevenZipSharp执行失败错误,c#,winforms,passwords,zip,7zip,C#,Winforms,Passwords,Zip,7zip,我最近尝试过使用NuGet压缩和解压文件 但是我不能压缩它们,错误可能来自dll库。我试过下载32位和64位的7zip,使用了这两个.dll,但错误是一样的,我想不出有什么办法 private void Compress(string source, string output) { /*32-bits version*/ string path = Directory.GetCurrentDirectory() + @"\32-7z.dll"; //64-
private void Compress(string source, string output)
{
/*32-bits version*/ string path = Directory.GetCurrentDirectory() + @"\32-7z.dll";
//64-bits version string path = Directory.GetCurrentDirectory() + @"\64-7z.dll";
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.Zip;
compressor.TempFolderPath = Path.GetTempPath();
compressor.CompressionMode = SevenZip.CompressionMode.Create;
compressor.CompressionLevel = SevenZip.CompressionLevel.Fast;
compressor.CompressionMethod = CompressionMethod.Lzma2;
compressor.ZipEncryptionMethod = ZipEncryptionMethod.Aes256;
var assemblyDllPath = compressor.TempFolderPath + "32-7z.dll";
//var assemblyDllPath = compressor.TempFolderPath + "64-7z.dll";
File.Copy(path, assemblyDllPath, overwrite: true);
SevenZipExtractor.SetLibraryPath(path);
compressor.CompressDirectory(@"A:\C#\random", @"A:\C#\empty\archive.zip", "password");
}
当im使用32位dll时,proyect设置为Debug x86。
当im使用64位dll时,proyect设置为Debug x64
在这两种情况下,错误如下:
SevenZip.SevenZipException
HResult=0x80131500
Message = Execution has failed due to an internal SevenZipSharp issue (0x80004001 / -2147467263).
Please report it to https://github.com/squid-box/SevenZipSharp/issues/, include the release number, 7z version used, and attach the archive.
Source = SevenZipSharp
我真的很感谢您为此投入的时间,提前感谢。您得到的错误代码(0x80004001)对应于错误“未实现”-这是因为您试图使用.zip格式不支持的压缩方法 除非您有特殊要求,否则我建议使用压缩模式.Default-否则以下使用.zip格式: 压缩方法。复制
压缩方法。放气
压缩方法。放气64
CompressionMethod.BZip2
压缩方法Lzma
CompressionMethod.Ppmd
这就是我从github上的squid box中得到的答案,只需将压缩方法更改为Lzma2。Lzma压缩方法。Lzma听起来像是由于内部SevenZipSharp问题而失败。也许你应该报告它,包括发行号,使用的7z版本,并附上存档。似乎要花很长时间才能得到答案,反正我开了罚单,你总是希望堆栈溢出可以帮助你,这是如何下载和解压缩文件,我还确信,您不需要任何dll或包,因为windows可以处理.zip文件