If I run this command in a command window, it runs fine giving the results I expect. I first go to the FilePath via CD FilePath
. Then run the command with a flag and send the output to the DestPath.
C:\Program Files (x86)\ProgramName\FileName.exe -f > C:\Temp\Test.txt
But, it is not running via the below process. I have gone through lots of forums and tried solutions, but none have worked.
public const string FilePath = @"C:\\Program Files (x86)\\ProgramName\\FileName.exe";
public const string DestPath = @"C:\\Temp\\Test.txt";
public static void GetResults()
{
ProcessStartInfo process = new ProcessStartInfo
{
UseShellExecute = true,
CreateNoWindow = false,
FileName = @"cmd",
};
string Command = @"/c " + FilePath + " -f > " + DestPath;
process.Arguments = Command;
process.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(process);
Thread.Sleep(2000);
Any suggestions on how to correct this issue or what I may be doing incorrectly?