728x90
반응형
파이썬이 설치된 PC이어야 하고,
파이썬 경로는 다를수있으니 3번째줄은 본인경로에맞게 수정
실행하면, ListView (list1)에 실행중에 발생된 에러가 표시된다.
string folder5 = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName.Replace("지금프로젝트", "파이썬프로젝트") + @"\파이썬파일.py";
var psi = new ProcessStartInfo();
psi.FileName = @"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe"; //파이썬 설치 경로
psi.Arguments = folder5; //파일경로
//3) Proecss configuration
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
//4) return value def
var erros = "";
var results = "";
using (var process = Process.Start(psi))
{
erros = process.StandardError.ReadToEnd();
results = process.StandardOutput.ReadToEnd();
}
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(delegate
{
list1.Items.Add(erros);
list1.Items.Add(results);
}));
if (erros.Length > 10)
{
G_G_Errorpython = true;
return;
}
|
cs |
728x90
반응형
'다양한 실전소스코드 > WPF(C#)' 카테고리의 다른 글
[Tip] 윈도우 핸들 누수 해결에 대한 생각.net WPF Winform C# handle leak 100만 (0) | 2022.01.28 |
---|---|
[Solved] WPF TextBox 한글/영어 키보드 자동으로 (0) | 2021.07.12 |
C# WPF ScrollViewer move to Origin (0) | 2021.06.29 |
[Solved] C# WPF Web Script Error (스크립트 에러 제거) (0) | 2021.06.29 |
[Solved] C# WPF Scrollview Position Get (스크롤 위치따라 반응) (0) | 2021.06.29 |
댓글