I get the error "Not implemented".
I want to compress a file using 7-Zip via stdin then take the data via stdout and do more conversions with my application. In the man page it shows this example:
% echo foo | 7z a dummy -tgzip -si -so > /dev/null
I am using Windows and C#.
Results:
7-Zip 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03
Creating archive StdOut
System error:
Not implemented
Code:
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();
}
Is there another simple way to read the file into memory?
Right now I can 1) write to a temporary file and read (easy and can copy/paste some code) 2) use a file pipe (medium? I have never done it) 3) Something else.
You might want to try out something like SevenZipSharp http://www.codeplex.com/sevenzipsharp, I've never used it personally but it provides a wrapper to the 7za.dll COM library which may be helpful to you.
I've written utilities that utilise 7-Zip via a process myself and haven't had issues though I've never tried to do StdIn and StdOut stuff. In the Help files I have with my version of 7-Zip the page on the -si switch states:
Note: The current version of 7-Zip does not support reading of archives from stdin.
Note sure if this might be the source of your problem, with specifying both switches it might be confusing 7-Zip.
The examples they show in the help seem to show that -so is used to redirect the output to standard out but requires normal file based inputs to do so.