C#에서 외부 어플리케이션을 실행하고플 때

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "FileName";
p.StartInfo.Arguments = "argument1 argument2 argument3";
// Redirection 설정
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;

p.Start();

// output 저장
using (StreamWriter pFileWriter = new StreamWriter("Log.txt", false, Encoding.Default))
{
        pFileWriter.WriteLine(p.StandardOutput.ReadToEnd());
}

+ Recent posts