본문 바로가기
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form
구분 팁&트릭
출처 내가작성
        private void ProcRunProc(string fileName, string Args = "")
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = fileName;
            startInfo.Arguments = Args;
            startInfo.CreateNoWindow = true;
            startInfo.UseShellExecute = false;
            startInfo.WorkingDirectory = gMain.g_CurPath;
                
            startInfo.RedirectStandardInput = true;
            Process Proc = new Process();
            Proc.StartInfo = startInfo;
            
            Proc.Start();
            Proc.WaitForExit();
        }


gMain.g_CurPath = 현재 디렉토리입니다. 


ShellExecute함수를 써서 외부 실행파일을 돌려도 되는데 이럴 경우 그 프로세스가 종료하기 전에 그냥 루틴이 이어집니다.

만약 종료하고 나서 진행되야 할 루틴일 경우 낭패이죠. 

이럴 경우 위 함수로 실행 시 WaitforExit()구문에 의해 프로세스가 종료 될 때까지 빠져나오지 않습니다.