프로젝트에서 명령 프롬프트를 사용해야합니다. 모든 것은 괜찮습니다. 그러나 출력은 내가 원하는 것이 아닙니다. 내가 이렇게하면 :C# 명령 프롬프트 출력
ProcessStartInfo info = new ProcessStartInfo("cmd","/c dir c:\\test");
info.RedirectStandardOutput = true;
info.RedirectStandardInput = true;
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process p = new Process();
p.StartInfo = info;
p.Start();
string iii = p.StandardOutput.ReadToEnd();
textBox1.Text = iii;
결과는 괜찮습니다. 정확히 내가 원하는대로. 하지만 좀 더 명령을 보내야합니다. 그래서 나는 이것을하고있다 :
ProcessStartInfo info = new ProcessStartInfo("cmd");
info.RedirectStandardOutput = true;
info.RedirectStandardInput = true;
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process p = new Process();
p.StartInfo = info;
p.Start();
StreamWriter write = p.StandardInput;
write.WriteLine("dir c:\\test");
write.Close();
string iii = p.StandardOutput.ReadToEnd();
textBox1.Text = iii;
그러나 결과는 이전과 같지 않다. cmd와는 달리 경로와 모든 것을 제공합니다. 원하지 않습니다. 명령 프롬프트에서만 결과가 필요합니다. 누군가가 도울 수 있기를 바랍니다. 내 문제를 읽어 주셔서 감사합니다.
글쎄, 나는 당신이 "dir c : \\ test"를 언급하고 있다고 가정하고있다. 그것은 설명하기 쉽다 : 당신 스스로 그것을 쓰고있다. 이전처럼/c를 통해 전달하십시오. – JerKimball
답장을 보내 주셔서 감사합니다. 내가 말했듯이이 빈 출력을 가지고 있습니다 ... – user1965804