开发者

How change encoding?

开发者 https://www.devze.com 2023-02-04 23:20 出处:网络
I need convert or set encoding windows-1251 Process p = new Process(); StreamWriter sw; StreamReader sr;

I need convert or set encoding windows-1251

Process p = new Process();
StreamWriter sw;
StreamReader sr;
StreamReader err;



ProcessStartInfo psI = new ProcessStartInfo("cmd");
psI.UseShellExecute = false;

psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
psI.CreateNoWindow = true;
p.StartInfo = psI;


p.Start();
sw = p.StandardInput;
sr = p.StandardOutput;
err = p.StandardError;



sw.AutoFlush = true;
if (tbComm.Text != "")
    sw.WriteLine(tbComm.Text);
else
    //execute default command
    sw.WriteLine("dir \\");


sw.Close();

textBox1.Text = sr.ReadToEnd();// this not support russian word. I need convert or set encoding 开发者_运维问答windows-1251
textBox1.Text += err.ReadToEnd();


You should be able to specify the encoding for the StandardOutput on your ProcessStartInfo before you point your StreamReader to it.

0

精彩评论

暂无评论...
验证码 换一张
取 消