2011-01-17 2 views
2

나는에 StandardOutput에 대한 specify the encoding에 당신은 할 수 있어야 변환하거나 창-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(); 

답변

0

를 인코딩 설정하셔야합니다 ProcessStartInfo 당신이 당신의 StreamReader 그것을 지적하기 전에.

+0

psI.StandardOutputEncoding = Encoding.GetEncoding (1251); - 도와주지 마. mayby는 StreamReader 인코딩을 변경합니까? – Mediator

+0

@simply denis : 내가 틀릴 수도 있지만'StreamReader' 인코딩은 생성시에만 설정할 수 있다고 생각합니다. 그 후에는 읽기 전용입니다. 'Process' 안에서 생성되고 있기 때문에,'Process' 나'ProcessStartInfo'에 어떻게 든 설정해야합니다. 나는 _think_ (필자는 지금 테스트 할 컴파일러 앞에 있지 않다). – David

관련 문제