Изменения документа System. Diagnostics. Process
Редактировал(а) Alexandr Fokin 2023/05/07 13:08
От версии 1.4
отредактировано Alexandr Fokin
на 2022/06/06 14:37
на 2022/06/06 14:37
Изменить комментарий:
Удаленный объект
К версии 2.1
отредактировано Alexandr Fokin
на 2022/06/06 14:40
на 2022/06/06 14:40
Изменить комментарий:
К данной версии нет комментариев
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,2 +1,36 @@ 1 1 Process.start: how to get the output? 2 2 https://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output 3 + 4 +---- 5 + 6 +Template 7 + 8 +{{code language="c#"}} 9 +ProcessStartInfo info = new ProcessStartInfo(); 10 +// fill info ... 11 + 12 +//token.ThrowIfCancellationRequested(); 13 +Process process = Process.Start(info); 14 +try 15 +{ 16 + await process.WaitForExitAsync(token); 17 +} 18 +catch (OperationCanceledException) 19 +{ 20 + process.Kill(true); 21 + await process.WaitForExitAsync(); 22 + throw; 23 +} 24 + 25 +var outputString = await process.StandardOutput.ReadToEndAsync(); 26 +var errorString = await process.StandardError.ReadToEndAsync(); 27 + 28 +if (process.ExitCode == 0) 29 +{ 30 + //Successe 31 +} 32 +else 33 +{ 34 + //Error 35 +} 36 +{{/code}}