Send binary data to the standardInput of a process

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

    Send binary data to the standardInput of a process

    I am writing a program in c#.

    I would like to read a binary file to the standard input of a process (it is
    flac.exe to encode/decode some files).

    I have tried to use the following code :

    StandardInputWr iter = convertProcess. StandardInput;
    [...]
    byteRead = SourceFileStrea m.Read(buff,0,B UFFER_LENGTH);
    StandardInputWr iter.BaseStream .Write(buff,0,b yteRead);

    but it fails with somes files (whith custom chunk in the .wav input file).
    However thhes files are well converted whne I use directly le flac.exe
    command line. So it is the wrinting on the standard input which fails.

    I think it is related to the fact that the standardInput is opened in text
    mode (it uses a streamWriter).. . is there an other way to write correctly
    binay data to the standard input of a process ?

    Thanks for your help

    O_Spring


  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Send binary data to the standardInput of a process

    hi,

    did you tried StreamWriter.Ba seStream?


    cheers,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "O_Spring" <ospring@mailfr ance.com> wrote in message
    news:42b935f2$0 $30776$626a14ce @news.free.fr.. .[color=blue]
    >I am writing a program in c#.
    >
    > I would like to read a binary file to the standard input of a process (it
    > is
    > flac.exe to encode/decode some files).
    >
    > I have tried to use the following code :
    >
    > StandardInputWr iter = convertProcess. StandardInput;
    > [...]
    > byteRead = SourceFileStrea m.Read(buff,0,B UFFER_LENGTH);
    > StandardInputWr iter.BaseStream .Write(buff,0,b yteRead);
    >
    > but it fails with somes files (whith custom chunk in the .wav input file).
    > However thhes files are well converted whne I use directly le flac.exe
    > command line. So it is the wrinting on the standard input which fails.
    >
    > I think it is related to the fact that the standardInput is opened in text
    > mode (it uses a streamWriter).. . is there an other way to write correctly
    > binay data to the standard input of a process ?
    >
    > Thanks for your help
    >
    > O_Spring
    >
    >[/color]


    Comment

    • O_Spring

      #3
      Re: Send binary data to the standardInput of a process

      Yes, I have... (StandardInput is a StreamWriter)



      "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > a
      écrit dans le message de news: uLvHAoydFHA.277 6@TK2MSFTNGP10. phx.gbl...[color=blue]
      > hi,
      >
      > did you tried StreamWriter.Ba seStream?
      >
      >
      > cheers,
      >
      > --
      > Ignacio Machin,
      > ignacio.machin AT dot.state.fl.us
      > Florida Department Of Transportation
      >
      >
      > "O_Spring" <ospring@mailfr ance.com> wrote in message
      > news:42b935f2$0 $30776$626a14ce @news.free.fr.. .[color=green]
      > >I am writing a program in c#.
      > >
      > > I would like to read a binary file to the standard input of a process[/color][/color]
      (it[color=blue][color=green]
      > > is
      > > flac.exe to encode/decode some files).
      > >
      > > I have tried to use the following code :
      > >
      > > StandardInputWr iter = convertProcess. StandardInput;
      > > [...]
      > > byteRead = SourceFileStrea m.Read(buff,0,B UFFER_LENGTH);
      > > StandardInputWr iter.BaseStream .Write(buff,0,b yteRead);
      > >
      > > but it fails with somes files (whith custom chunk in the .wav input[/color][/color]
      file).[color=blue][color=green]
      > > However thhes files are well converted whne I use directly le flac.exe
      > > command line. So it is the wrinting on the standard input which fails.
      > >
      > > I think it is related to the fact that the standardInput is opened in[/color][/color]
      text[color=blue][color=green]
      > > mode (it uses a streamWriter).. . is there an other way to write[/color][/color]
      correctly[color=blue][color=green]
      > > binay data to the standard input of a process ?
      > >
      > > Thanks for your help
      > >
      > > O_Spring
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...