开发者

c++ process start problem with path

开发者 https://www.devze.com 2023-01-10 14:00 出处:网络
I\'m using process::start(PATH); to open up the process. The problem is, sometimes 开发者_C百科it finds the file and sometimes it doesn\'t.

I'm using process::start(PATH); to open up the process. The problem is, sometimes 开发者_C百科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. 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.

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:

process::start("\"C:\\New Folder\\text.exe\"");
0

精彩评论

暂无评论...
验证码 换一张
取 消