"Given Path Format Is Not Supported"...你能帮帮我吗?

"Given Path Format Is Not Supported"... Can you help me?

所以,我做了一个语音识别器,它工作正常,我不确定为什么它现在给我这个错误。有什么想法吗?

String res = e.Result.Text;

string yol = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
            string settings = ("@" + yol + "\" + "settings" + "\");


            if (res == "Hi Bot")
            {
              pictureBox1.Image = Image.FromFile(settings + "mybot.png"); -->That's where i get the error
              say(greetings_random());
            }
string yol = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
string settings = ("@" + yol + "\" + "settings" + "\");

这意味着 settings 的值为 "@C:\Path\To\Executable\settings\"

这可能不是您想要的——我不确定 @ 试图实现什么,但它在这样的路径的开头是无效的。

将来,调试此代码并检查 settings 变量会很快发现问题。


也就是说,建议使用 Path.Join (.NET Core 2.1+) or Path.Combine 而不是字符串连接来创建这样的路径。