I have a bat file, which copies files from one directory to other. If this bat file is clicked manually, files are copied succesfully and no issues with that. But if bat file is executed through C#, "files not found" message is displayed in the cmd window.
Here is my bat file.
echo off
echo.
XCOPY "..\SourceFolder\CaSourceFile" "..\DestinationFolder\SubFolder" /r /Y /i /F
if full path is given in bat file, then files are copied successfully. example,
XCOPY "D:\RootFolder\SourceFolder\CaSourceFile" "D:\RootFolder\DestinationFolder\SubFolder" /r /Y /i /F
My C# code:
ProcessStartInfo processInfo = new ProcessStartInfo(batchFile);
processInfo.UseShellExecute = true;
Process batchProcess = new Process();
batchProcess.StartInfo.FileName = "cmd.exe";
batchProcess.StartInfo = processInfo;
batchProcess.StartInfo.Arguments = String.Format("\"{0}\" \"{1}\"", @"D:\Europa\Test Release Tool\SingleExeInstaller\EuropaApplication", @"D:\Europa\Test Release Tool\SingleExeInstaller\EuropaInstaller");
batchProcess.StartInfo.RedirectStandardInput = true;
batchProcess.StartInfo.RedirectStandardOutput = true;
batchProcess.StartInfo.RedirectStandardError = true;
batchProcess.Start();
batchProcess.WaitForExit();
My application exe is available in C: and bat file is available in D: Is there any idea to over come this issue ? Kindly help me out.