I have a SQL Job that's running on a DB Server and on one of the steps it calls an application server to run an exe "cmd Exec step type"
the exe application "C#" is invoked properly and does all its intended tasks, as a final step it runs cmd.exe to merge couple of files.
** When running the exe application manually, it's working as intended, but when invoking through SQL Job it's returning the below error:
Error in MergeFiles() Method : System.ComponentModel.Win32Exception (0x80004005): The directory name is invalid
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at _700CreditBillingScheduler.Billing700C.MergeFilesInPath()
Worth saying everything is running on E:\ drive
Here is my code:
string filePath = "E:\\HomeFolder\\ApplicationFolder"; // where merged file will be created
string sourcePath = "E:\\HomeFolder\\ApplicationFolder\\Transaction.Indiv.Files\\*.csv"; // to be merged
string commandLine = String.Format("/c copy /b {0} {1}", sourcePath, "mergedFileName");
var cmd = new ProcessStartInfo("cmd.exe", commandLine);
cmd.WorkingDirectory = filePath;
cmd.UseShellExecute = false;
Process.Start(cmd);