[英]c++ process start problem with path
I'm using process::start(PATH);
我正在使用
process::start(PATH);
to open up the process. 打开过程。 The problem is, sometimes it finds the file and sometimes it doesn't.
问题是,有时会找到文件,有时却找不到。
For example, this works: 例如,这有效:
process::start("C:\text.exe");
But this doesn't work: 但这不起作用:
process::start("C:\New Folder\text.exe");
Any idea what the difference is? 知道有什么区别吗?
You have to escape the \\
characters. 您必须转义
\\
字符。
In a C string \\t
is the TAB character. 在C字符串中,
\\t
是TAB字符。 Use: 采用:
process::start("C:\\New Folder\\text.exe");
The library might think that c:\\New is the program you are running, and Folder\\text.exe is an argument you are passing to it. 该库可能认为c:\\ New是您正在运行的程序,而Folder \\ text.exe是您要传递给它的参数。
You might need to quote it, so you're calling this: 您可能需要引用它,因此您将其称为:
"C:\New Folder\text.exe"
Which as a C++ string would look like this: 作为C ++字符串,它看起来像这样:
process::start("\"C:\\New Folder\\text.exe\"");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.