I have implementation where I run an *.EXE through the command prompt using System.Diagnostic.Process
.
This works perfectly fine in English OS. However, to support multilingual- I have changed OS display language to French. When I run the same code, it does not do anything. However NO ERROR/EXCEPTION.However, Non English does not do anything (command does not seems to be executed).
Below is the sample code I used,
Process pdfProcess = new Process();
StreamWriter writer;
StreamReader reader;
ProcessStartInfo info = new ProcessStartInfo("cmd");
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
info.WorkingDirectory = exePath; //Path where Invoke exe located
pdfProcess.StartInfo = info;
pdfProcess.Start();
writer = pdfProcess.StandardInput;
reader = pdfProcess.StandardOutput;
writer.AutoFlush = true;
writer.WriteLine(command);
writer.Close();
string ret = reader.ReadToEnd();
The issue is the file name. In non-English languages, special characters are getting added to the file name which is not getting executed by above code. For example:
command = MyEXE.exe "C:\Sin título_ Bloc de notas.txt"
If you see above (Spanish), "í" text is causing the issue. If I remove it them command gets executed.
Anyone has solution how to resolve it?