【发布时间】:2024-01-02 00:31:01
【问题描述】:
然后我用 tar 压缩然后 gzip C# 中的文件列表。
我需要一些关于如何将参数设置为 tar 的帮助。
假设我在文件夹 c:\tar\tar.exe 中有 tar.exe 和如下方法:
private void RunTar(string outputFileName, List<string> fileNamePaths)
{
using (Process p = new Process())
{
p.StartInfo.FileName = @"c:\tar\tar.exe";
p.StartInfo.Arguments = //;
p.Start();
p.WaitForExit();
}
}
注意:fileNamePathsToTar 列表包含完整的 unc 文件名路径,文件可以位于不同的文件夹中。
谁能帮忙提供什么论据。
我还在文档中注意到:
-z, --gzip, --ungzip
filter the archive through gzip
-Z, --compress, --uncompress
filter the archive through compress
--use-compress-program=PROG
filter through PROG (must accept -d)
不确定如何使用它,但如果我将 gzip.exe 与 tar.exe 放在同一文件夹中我可以在一个步骤中执行我的 tar 然后对这些文件进行 gzip 处理? p>
更新
如果我尝试使用完整路径名,我似乎只能让 tar 处理与 tar.exe 位于同一目录中的文件,但会得到如下信息:
C:\Tar Test>tar -cf out.tar c:/Tar Test/Text/t1.txt
tar: Cannot add file c:/Tar: No such file or directory
tar: Cannot add file Test/Text/t1.txt: No such file or directory
tar: Error exit delayed from previous errors
我已经尝试过使用斜线 \ 或 / 并在完整路径周围加上引号没有乐趣。
谢谢
【问题讨论】:
-
我建议在 SuperUser 上询问这个无进程。
-
试试这个方法 C:\Tar Test>tar -cf out.tar "c:/Tar Test/Text/t1.txt"
-
嘿,工作 C:\Tar Test>tar -cf out.tar "c:/Tar Test/Text/t1.txt" 什么不工作是 C:\Tar Test>tar - cf "c:/out.tar" "c:/Tar Test/Text/t1.txt"。所以我可以从完整路径读取文件,但不能仅在本地输出到任何位置。
-
另外,我只能让它对 1 个文件起作用,我希望能够提供文件列表,知道格式吗?
标签: c# windows process gzip tar