C#C
C#3y ago
Karbust

❔ Process Start with unicode characters

Hello,

I'm having issues with the following code to launch process when they are on directories with unicode characters, like, for example, C:\Users\fehmikır\Desktop\test. It works without problems on paths without unicode characters.

No error is thrown, the execution is "successful", but the application doesn't open. This also happens when manually running the application within a folder with such characters. Launching the process through Electron using the spawn command also works.

public bool Startup(string applicationName, string commandLine = "", string currentDirectory = "")
{
    try
    {
        Environment.CurrentDirectory = currentDirectory;
        
        ProcessStartInfo startInfo = new ProcessStartInfo
        {
            FileName = applicationName,
            Arguments = commandLine,
            WorkingDirectory = currentDirectory
        };
    
        Process.Start(startInfo);
        
        return true;
    } 
    catch (Exception e)
    {
        m_logFile.WriteArgs("Error while trying to start process [{0}] with command line [{1}] in directory [{2}]", applicationName, commandLine, currentDirectory);
        m_logFile.WriteArgs("Exception: {0}", e);
        return false;
    }
}


Electron code:
const spawnClient = spawn(`${Main.clientFolderPath}\\${binaryName}`, launchParameters, {
    detached: true,
    cwd: `${Main.clientFolderPath}\\${clientPath}`,
})


Does anyone have any idea on how to solve this?

Thank you
image.png
Was this page helpful?