如何在 c# 和 dotnet 中获取 cmd 的输出
本文关键字:获取 cmd 输出 dotnet | 更新日期: 2023-09-27 18:36:56
我尝试将推荐发送到cmd并获得输出。我确定它已发送,但我无法获得输出。
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.FileName = @"C:'Users'mehmetcan'Desktop'adt-bundle-windows-x86-20130917'sdk'platform-tools'adb.exe";
startinfo.Arguments = @"devices";
startinfo.RedirectStandardOutput = true;
startinfo.RedirectStandardError = true;
startinfo.UseShellExecute = false;
// Note: declare process as a variable in the class as it needs to be used in the event handlers
process = new Process();
process.StartInfo = startinfo;
它返回:"123456设备"如何将其放入字符串中?
你应该通过以下方式阅读它
string output = process.StandardOutput.ReadToEnd();