I'm having a problem with some Swedish characters.
I'm sending and reading from the command-line, cmd.exe, and I get the output alright when setting the CodePage to 850, Western European (DOS).
The problem is that if I send a string that contains a Swedish character it gets screwed up and cmd.exe can't understand what I mean.
I use this to browse my drives and if I try to cd a directory with a Swedish character in it I get "The system cannot find the path specified." as a response.
Does anyone have an idea on this?
Expand|Select|Wrap|Line Numbers
- private Process proc;
- private ProcessStartInfo ps;
- ps = new ProcessStartInfo();
- ps.CreateNoWindow = true;
- ps.FileName = "cmd.exe";
- ps.UseShellExecute = false;
- ps.RedirectStandardInput = true;
- ps.RedirectStandardOutput = true;
- ps.RedirectStandardError = true;
- ps.StandardOutputEncoding = Encoding.GetEncoding(850);
- proc = new Process();
- proc.StartInfo = ps;
- proc.Start();
- proc.StandardInput.WriteLine( cmd );
- proc.StandardInput.WriteLine("exit");
- string line = proc.StandardOutput.ReadToEnd();
- string error = proc.StandardError.ReadToEnd();
- proc.Close();