C
C#2mo ago
Dưa Hấu

.NET

var process = new Process();
var start = new ProcessStartInfo()
{
CreateNoWindow = false,
UseShellExecute = false,
RedirectStandardOutput = true,
FileName = @"adb\adb.exe",
Arguments = "-s " + deviceID + " shell screencap -p",
Verb = "runas"
};

process.StartInfo = start;
process.Start();
var stream = process.StandardOutput.BaseStream;
var process = new Process();
var start = new ProcessStartInfo()
{
CreateNoWindow = false,
UseShellExecute = false,
RedirectStandardOutput = true,
FileName = @"adb\adb.exe",
Arguments = "-s " + deviceID + " shell screencap -p",
Verb = "runas"
};

process.StartInfo = start;
process.Start();
var stream = process.StandardOutput.BaseStream;
+ ExitCode 'process.ExitCode' threw an exception of type 'System.InvalidOperationException' int {System.InvalidOperationException}
1 Reply
canton7
canton72mo ago
Looks like you might be reading process.ExitCode while the process is sitll running? https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.exitcode?view=net-8.0#exceptions . Your code doesn't access .ExitCode though, so you're probably not sharing enough code. The exception message should give you more detail Note, this was cross-posted to #chat Please don't cross-post. it just means that different people end up answering the same question in different places, which wastes everyone's time
Want results from more Discord servers?
Add your server