As title. I want to do something to DOCKER on a server with no DOCKER DESKTOP easily, so I've read How To: Execute command line in C#, get STD OUT results , and I make my code as this:
CmdProcess = new Process();
CmdProcess.StartInfo.FileName = "cmd.exe";
CmdProcess.StartInfo.CreateNoWindow = true;
CmdProcess.StartInfo.UseShellExecute = false;
CmdProcess.StartInfo.RedirectStandardInput = true;
CmdProcess.StartInfo.RedirectStandardOutput = true;
CmdProcess.StartInfo.RedirectStandardError = true;
CmdProcess.Start();
CmdProcess.StandardInput.WriteLine("/K docker images");
output = CmdProcess.StandardOutput.ReadToEnd();
if (output != string.Empty)
{
MessageBox.Show(output, "Docker Image Show", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
MessageBox.Show("No data", "Docker Image Show", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
and I got stuck at the line to get output value, no response, just like running into a infinite loop. Could someone guide me to solve this?