tôi đang cố gắng để có được quá trình phản ứng như là một chuỗi để tôi có thể sử dụng nó ở vị trí khác nhau trong mã của tôi, đây là giải pháp mà tôi có cho đến nay:"Hệ thống không thể tìm thấy tệp được chỉ định" lỗi trên 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());
}
Nhưng khi tôi đang chạy tôi này nhận được:
"The system cannot find the file specified" error in process.Start(); without process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true;
mã này chạy tốt nhưng nó chỉ mở giao diện điều khiển cửa sổ và tất cả các phản ứng quá trình là niềm tin đó vì vậy tôi không thể sử dụng nó như là chuỗi.
Có ai biết tại sao tôi gặp phải lỗi này hoặc có thể là một giải pháp khác cho vấn đề của tôi?
Nó hoạt động! cảm ơn ! –
@DariaShalimov nếu đây là câu trả lời cho câu hỏi của bạn, hãy đánh dấu là câu trả lời – Jamaxack
Tôi có thể làm như thế nào? –