I've had a google search and looked through Stackoverflow answers already and can't find anything similar so I thought I'd make a question myself.
using System;
using System.IO;
using System.Diagnostics;
namespace changesProgram3
{
public class Program
{
//Check to see if changes are made to a text file
static void Main()
{
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "testbat.bat";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
Console.WriteLine(output);
}
}
}
It breaks on the "p.Start();" line during runtime with the error message: "The system can not find the file specified". I can't for the life of me work out what is going wrong. The testbat.bat file is in the same directory as the .csproj so perhaps it can't find that for some reason. Any help would be appreciated. Thanks.