然后我使用 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 这些文件吗?
更新
如果我尝试使用完整路径名,我似乎只能让 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
我已经尝试过使用斜线 \ 或 / 并在完整路径周围加上引号没有乐趣。
谢谢