iv 尝试了许多不同的方法来让它工作,我让它基本上工作,但我无法得到 WaitForExit(); 就像他们在这里一样工作......那么我将如何将其转换为与sevenzip一起使用?因为我无法让它工作,而且我的 SFX 是密码的,所以它们不能被访问,除非通过使用程序和添加 7z.DLL 我无法添加它,因为我收到错误:
无法添加对 7za.dll 的引用。请确保该文件是可访问的,并且它是一个有效的程序集或 COM 组件。
string tempFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
System.Diagnostics.Process defrag1 = System.Diagnostics.Process.Start(@"AusLogics_Defrag.exe", string.Format(" -o{0} -y -Pthisisthepass", tempFolder));
defrag1.WaitForExit();
string executableDirectoryName = Path.GetDirectoryName(Application.ExecutablePath);
System.Diagnostics.Process defrag2 = System.Diagnostics.Process.Start(tempFolder + "\\" + "AusLogics_Defrag" + "\\" + "DiskDefrag.exe", "");
defrag2.WaitForExit();
System.IO.Directory.Delete(tempFolder + "\\" + "AusLogics_Defrag", true);
新:好的,这就是我目前所拥有的,但我收到错误“无法加载 7-zip 库或内部 COM 错误!消息:加载库失败”
SevenZipExtractor.SetLibraryPath("7z.dll"); //no idea of this is needed or not
SevenZipCompressor.SetLibraryPath("7z.dll"); //no idea of this is needed or not
string tempFolder = Environment.GerFolderPath(Environment.SpecialFolder.ApplicationData);
SevenZipExtractor defrag = new SevenZipExtractor(@"Programs\Optimize\Auslogics_Defrag.7z");
defrag.ExtracArchive(string.Format("-o{0} -y -PThisisthepass", tempFolder));