Send binary data to the standardInput of a process

O

O_Spring

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 :

StandardInputWriter = convertProcess.StandardInput;
[...]
byteRead = SourceFileStream.Read(buff,0,BUFFER_LENGTH);
StandardInputWriter.BaseStream.Write(buff,0,byteRead);

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
 
O

O_Spring

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



Ignacio Machin ( .NET/ C# MVP ) said:
hi,

did you tried StreamWriter.BaseStream?


cheers,

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


O_Spring said:
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 :

StandardInputWriter = convertProcess.StandardInput;
[...]
byteRead = SourceFileStream.Read(buff,0,BUFFER_LENGTH);
StandardInputWriter.BaseStream.Write(buff,0,byteRead);

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top