Ich versuche, den Prozess zu reagieren als String zu bekommen, damit ich es in anderem Ort in meinem Code verwenden kann, ist dies die Lösung, die ich bisher:Fehlermeldung "Das System kann die angegebene Datei nicht finden" bei process.Start();
const string ex1 = @"C:\Projects\MyProgram.exe ";
const string ex2 = @"C:\Projects\ProgramXmlConfig.xml";
Process process = new Process();
process.StartInfo.WorkingDirectory = @"C:\Projects";
process.StartInfo.FileName = "MyProgram.exe ";
process.StartInfo.Arguments = ex2;
process.StartInfo.Password = new System.Security.SecureString();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
try
{
process.Start();
StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();
}
catch (Exception exception)
{
AddComment(exception.ToString());
}
Aber wenn ich diesen Mich renne erhalten:
"The system cannot find the file specified" error in process.Start(); without process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true;
der Code läuft gut, aber es nur offene Konsolenfenster und die alle Prozessantwort ist trow es so kann ich es nicht als Zeichenfolge verwenden.
Weiß jemand, warum ich diesen Fehler oder vielleicht eine andere Lösung für mein Problem bekomme?
Es hat funktioniert! Vielen Dank ! –
@DariaShalimov Wenn dies die Antwort auf Ihre Frage ist, markieren Sie als Antwort – Jamaxack
Wie kann ich das tun? –