2 years ago

#76591

test-img

Mcubed333

System.NotSupportedException when reading from StreamReader of the standard output of a DOSBox process in a C# Console Application

I am running into an issue reading the output/input of a DOSBox Process started by my C# console application. DOSBox has an encoding for code page 437, but setting up my StreamReader with that encoding is giving me a NotSupportedException. It is worth the noting, the StreamReader/Writer are not throwing an error when being set up, but no input/output is being sent. Upon debugging, the exception is thrown throughout the object.

This is how I am starting my DOSBox Process:

ProcessStartInfo startInfo = new ProcessStartInfo()
{
    FileName = "<path-to-DOSBox.exe>",
    Arguments = "<path-to-game> -noconsole",
    UseShellExecute = false,
    RedirectStandardInput = true,
    RedirectStandardOutput = true,
    RedirectStandardError = true,
};
process = new Process();
process.StartInfo = startInfo;
process.Start();

And then this is how I am attempting to read/write to the DOSBox console:

input = new StreamWriter(process.StandardInput.BaseStream, Encoding.GetEncoding(437));
input.WriteLine(command);

output = new StreamReader(process.StandardOutput.BaseStream, Encoding.GetEncoding(437));
Console.WriteLine(output.ReadToEnd());

I am registering the specific encoding with:

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

Here is a screenshot upon inspection of my StreamReader output:

1

c#

process

streamreader

streamwriter

dosbox

0 Answers

Your Answer

Accepted video resources