I'm currenty trying to write a GUI around
First I run a command to start the actual conversion of a image.
After that method I want to move the converted file to a different folder by MoveFile()
.
The problem is that the program doesn't wait for the CMD process to be finished and it wants to move the file immediately. When I'm debugging the program and actually letting it finish the CMD command, the file will be moved with no problems.
From reading online I need to use .WaitForExit()
but it doesn't seem to do much.
RunCommand(strCommand);
MoveFile(strDirectoryName + "\\" + strNewName, strDirectoryName + "\\0 - Preview\\" + strNewName);
RunCommand()
private void RunCommand(string CmdText) {
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c " + CmdText;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
Any helpers?