Problems reading StandardOutput as binary

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dansan

    #1

    Problems reading StandardOutput as binary

    I have been tryning to make some of our C# programs talk to some perl
    programs. These perl jewels output in binary. I have been trying to
    use Process.Standar dOutput to read the output from the perl programs.

    I am able to read the output if it is ASCII (or some char[] of some
    sort). But the issues comes when it is binary info. I have tried to
    use StandardOutput. BaseStream, which returns a Stream to then read the
    bytes out of that Stream. This stream does not support 'searching',
    therefore I can't do .Length on it... and I can't loop-until-done
    because I don't know how to stop when I'm at the end of the stream.

    I have tried all kinds of lines, one of which is:

    byte [] buffer = new byte [size];
    while ((buffer = binreader.ReadB ytes(buffer.Len gth)) != null)
    {
    .... write the buffer to a binary file...
    }

    but that doesn't work.

    I have also tried to read one byte at a time, but with no success
    either.


    How can I do this? Where can I read more about it?

    Thanks for helping :)

    Daniel.
  • Jon Skeet

    #2
    Re: Problems reading StandardOutput as binary

    dansan <islandlogic@ho tmail.com> wrote:[color=blue]
    > I have been tryning to make some of our C# programs talk to some perl
    > programs. These perl jewels output in binary. I have been trying to
    > use Process.Standar dOutput to read the output from the perl programs.
    >
    > I am able to read the output if it is ASCII (or some char[] of some
    > sort). But the issues comes when it is binary info. I have tried to
    > use StandardOutput. BaseStream, which returns a Stream to then read the
    > bytes out of that Stream. This stream does not support 'searching',
    > therefore I can't do .Length on it... and I can't loop-until-done
    > because I don't know how to stop when I'm at the end of the stream.[/color]

    You stop at the end of the stream by noting when Read returns -1. See
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.


    However, I don't know whether some other encoding stuff may get applied
    to the stream before you get a chance to look at it. It doesn't "feel"
    like a nice thing, I'm afraid...

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • dansan

      #3
      Re: Problems reading StandardOutput as binary

      Thanks.

      Comment

      Working...