Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# tar(在Windows上)c语言中的文件列表#_C#_Windows_Process_Gzip_Tar - Fatal编程技术网

C# tar(在Windows上)c语言中的文件列表#

C# tar(在Windows上)c语言中的文件列表#,c#,windows,process,gzip,tar,C#,Windows,Process,Gzip,Tar,然后,我将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.

然后,我将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();
        }
    }
不知道如何使用,但如果我将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
我试过用斜杠双向\或/或在完整路径周围加引号,没有乐趣


感谢创建存档并对其进行gzip,您应该使用czf作为参数,所以

p.StartInfo.Arguments = "czf";

取决于焦油版本

要避免gzip,请从参数中删除“z”


啊,你最好对整个文件夹进行tar,比如将所有文件放在一个名为myfolder的文件夹中,并对该文件夹进行tar,而不是对其内容进行tar。

供参考,在


有一个makefile允许您构建Tar.dll或Tar.exe。VB中还有一个示例应用程序

我建议在超级用户上使用这个w/o进程。试着用这种方法C:\Tar Test>Tar-cf out.Tar“C:/Tar Test/Text/t1.txt”嘿,它可以工作C:\Tar Test>Tar-cf out.Tar“C:/Tar Test>Tar-cf”C:/out.Tar“C:/Tar Test/Text/t1.txt”。因此,我可以从完整路径读取文件,但不能仅在本地输出到任何位置。此外,我只能对1个文件执行此操作,我想能够提供一个文件列表,知道格式吗?-cvf可以工作,但是当我尝试czf时,我得到:C:\Tar Test>Tar-czf out.Tar t1.txt Tar:Cannot fork:Function not implemented Tar:Error not recoverable:exiting nowtry out.Tar.gz,not just out.Tar实际不同的错误现在无法fork。C:\Tar Test>Tar-czf out.Tar.gz“C:/Tar Test/Text/t1.txt”Tar:Cannot fork:Function not implemented Tar:Error not recoverable:now退出,因为Tar只支持类unix路径。另一个解决方案是将“cd”发送到该目录并以相对路径运行。
p.StartInfo.Arguments = "czf";
p.StartInfo.Arguments = "-czf";