I am trying to make a chess engine run in the background from an interface i designed
Process stockfish;
stockfish = new Process {
StartInfo = new ProcessStartInfo {
FileName = System.IO.Directory.GetCurrentDirectory () + "\\Assets\\Scripts\\Stockfish\\stockfish.exe",
Arguments = "",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
};
try{
stockfish.Start();
}
catch (Exception e) {
print (e);
}
The code is throwing an exception
System.ComponentModel.Win32Exception: ApplicationName='E:\Narsun Projects\Ahmad's Projects\CoachChess\Narsun-CoachChess-Unity\Assets\Scripts\Stockfish\stockfish.exe', CommandLine='', CurrentDirectory=''
at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0
at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
'in your directory name, you should try a directory without'\$\endgroup\$'and it works now? \$\endgroup\$'or"you should escape them with a\. You could run a replace function on the directory first (should work like this if it's a String):System.IO.Directory.GetCurrentDirectory().Replace("'","\'")\$\endgroup\$@"\n\o\e\s\c\a\p\e!"See msdn.microsoft.com/en-us/library/362314fe.aspx \$\endgroup\$