Not able to use 7-Zip to compress stdin and output with stdout?

Posted by acidzombie24 on Stack Overflow See other posts from Stack Overflow or by acidzombie24
Published on 2009-08-17T11:12:31Z Indexed on 2010/04/25 5:23 UTC
Read the original article Hit count: 505

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about 7zip