我對我的項目中引用的DLL文件:在Form1的頂部我加SevenZipSharp.dll
我試圖用壓縮一些SevenZipSharp文件,但得到一個錯誤
然後:
using SevenZip;
然後創建我是從一個按鈕單擊事件調用函數:
private void Compress()
{
string source = @"C:\Users\bout0_000\AppData\Local\Diagnostic_Tool_Blue_Screen\Diagnostic Tool Blue Screen\SF_02-08-13";
string output = @"D:\Zipped.zip";
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.Zip;
compressor.CompressionMode = CompressionMode.Create;
compressor.TempFolderPath = System.IO.Path.GetTempPath();
compressor.CompressDirectory(source, output);
}
我用的斷點和錯誤就行了:
compressor.CompressDirectory(source, output);
但我發現了一個錯誤:
Cannot load 7-zip library or internal COM error! Message: DLL file does not exist
但我已經引用的DLL,爲什麼這個錯誤?我該如何解決它?
問題解決了:
private void Compress()
{
string source = @"C:\Users\bout0_000\AppData\Local\Diagnostic_Tool_Blue_Screen\Diagnostic Tool Blue Screen\SF_02-08-13";
string output = @"D:\Zipped.zip";
SevenZipExtractor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.Zip;
compressor.CompressionMode = CompressionMode.Create;
compressor.TempFolderPath = System.IO.Path.GetTempPath();
compressor.CompressDirectory(source, output);
}
你是否設置了dll來複制本地? –
lc我添加的dll作爲參考SevenZipSharp.dll屬性複製本地已設置爲true。但如果即時通過某人在這裏尋找解決方案:http://blog.jongallant.com/2011/10/7-zip-dll-file-does-not-exist.html#.UfyCWZIzO0I我看到該文件的DLL文件應該是7z.dll我不知道該怎麼辦。 – DanielVest