gpt4 book ai didi

c# - 如何使用 7zip 压缩目录?

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:36 25 4
gpt4 key购买 nike

我正在尝试使用 7zip 压缩目录,但它不起作用,也没有给出错误/异常

代码

 string sourceCompressDir = @"c:\7ziptest\TestFolder";
string targetCompressName = @"c:\7ziptest\TestFolder.zip";
ProcessStartInfo pCompress = new ProcessStartInfo();
pCompress.FileName = "7za.exe";

//Not working for below arguments
pCompress.Arguments = "7z a " + targetCompressName + " " + sourceCompressDir";

pCompress.WindowStyle = ProcessWindowStyle.Hidden;
pCompress.UseShellExecute = false;
Process x = Process.Start(pCompress);
x.WaitForExit();

有人可以指导我吗?我正在关注链接 http://www.dotnetperls.com/7-zipCOMMAND LIST FOR 7ZIP

我已经尝试直接使用命令提示符,但没有一个命令适合我!

1) C:>c:\7ziptest/7za.exe 7z a -tzip "c:\7ziptest\TestFolder.zip""c:\7ziptest\tes 文件夹”

    7-Zip (A) 4.42  Copyright (c) 1999-2006 Igor Pavlov  2006-05-14


Error:
Incorrect command line

2) C:>c:\7ziptest/7za.exe 7z a -tzip "c:\7ziptest\TestFolder.zip""c:\7ziptest\tes t文件夹\"

    7-Zip (A) 4.42  Copyright (c) 1999-2006 Igor Pavlov  2006-05-14


Error:
Incorrect command line

3) C:>c:\7ziptest/7za.exe 7z a -tzip "c:\7ziptest\TestFolder.zip""c:\7ziptest\tes tfolder\"-mx=9

    7-Zip (A) 4.42  Copyright (c) 1999-2006 Igor Pavlov  2006-05-14


Error:
Incorrect command line

谁能帮我找出上面命令中的错误!!!

最佳答案

D:\>7za a -tzip arch.zip "D:\dirName"

这对我有用。

所以 C# 代码中的等效参数应该是:

pCompress.Arguments = "a -tzip \"" + targetCompressName + "\" \"" + sourceCompressDir +"\"";

关于c# - 如何使用 7zip 压缩目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25174564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com