![](/img/trans.png)
[英]How do I retrieve only one specific file from a 7z instead of unzipping and dumping to a folder?
[英]how to get extended error information from 7z commandLine process
在我的C#應用程序中,我運行7z進程以將存檔提取到其目錄中
例如,歸檔文件位於%TEMP%目錄中的隨機命名目錄中
C:\\ Documents and Settings \\ User \\ Local Settings \\ Temp \\ vtugoyrc.fd2
(fullPathFilename =“ C:\\ Documents and Settings \\ User \\ Local Settings \\ Temp \\ vtugoyrc.fd2 \\ xxx.7z”)
我的代碼是:
sevenZipProcessInfo.FileName = SEVEN_ZIP_EXECUTABLE_PATH;
sevenZipProcessInfo.Arguments = "x " + fullPathFilename;
sevenZipProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
sevenZipProcessInfo.UseShellExecute = true;
sevenZipProcessInfo.WorkingDirectory = Path.GetDirectoryName(fullPathFilename);
Process sevenZipProcess = Process.Start(sevenZipProcessInfo);
if (sevenZipProcess != null)
{
sevenZipProcess.WaitForExit();
if (sevenZipProcess.ExitCode != 0)
...exit code is 2 (fatal error by the 7z help)
在哪里可以找到更詳盡的文檔?
您在這里使用7 Zip作為外部過程。 這等效於直接從命令行調用命令。
您是否考慮過使用實際的庫來壓縮/解壓縮文件。 您可以在C#項目中引用的內容。
Sharp Zip Lib眾所周知,但是這里有一個使用7zip存檔的特定包裝庫
感謝所有幫助。
無論如何,問題是使用“長路徑名”->命令行過程找不到C:\\ Documents and Settings \\(由於名稱中有空格)。 解決方案可以在這里找到在.net中轉換為短路徑的標准方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.