I'm attempting to run the below SQL Server BCP command as a Process, but I'm getting the error, "Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot find the file specified." What could be causing this? It runs fine using "Process.Start(Environment.GetEnvironmentVariable("COMSPEC")," /c bcp...", but I want it to wait before exiting; hence, the need for a Process.
Process p = new Process();
p.StartInfo.FileName = "bcp MyDB.dbo.MyTable in MyFile -m 1 -c -S MyServer -U MyUserId -P MyPassword";