我遇到了“未实现”的错误。
我想使用7-Zip通过stdin压缩文件,然后通过stdout获取数据并在我的应用程序中进行更多的转换。在man页面中,它显示了这个例子: % echo foo | 7z a dummy -tgzip -si -so > /dev/null 我正在使用Windows和C#。
结果:
我想使用7-Zip通过stdin压缩文件,然后通过stdout获取数据并在我的应用程序中进行更多的转换。在man页面中,它显示了这个例子: % echo foo | 7z a dummy -tgzip -si -so > /dev/null 我正在使用Windows和C#。
结果:
7-Zip 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03
Creating archive StdOut
System error:
Not implemented
代码:
public static byte[] a7zipBuf(byte[] b)
{
string line;
var p = new Process();
line = string.Format("a dummy -t7z -si -so ");
p.StartInfo.Arguments = line;
p.StartInfo.FileName = @"C:\Program Files\7-Zip\7z.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.Start();
p.StandardInput.BaseStream.Write(b, 0, b.Length);
p.StandardInput.Close();
Console.Write(p.StandardError.ReadToEnd());
//Console.Write(p.StandardOutput.ReadToEnd());
return p.StandardOutput.BaseStream.ReadFully();
}
有没有其他简单的方法将文件读入内存?
目前我可以 1)先写入临时文件然后再读取(容易操作,可以复制/粘贴一些代码)2)使用文件管道(中等难度?我从未尝试过)3)其他方法。