Open file wont work, it says wrong path
I'm testing out how to open files with C++ and I've come across a problem. It seems when I try to open a path that has no spaces in it, it works fine. But when I try to open a path with spaces it has an error message that says could not open file and it spouts the path but it stops short where the space is and doesn't seem to read the link after the space occured. Does anyone know what I'm doing wrong?
For instance this does not work:
Code:
#include <stdafx.h>
#include <iostream>
using namespace std;
#include <fstream>
int main()
{
system("START C:\\Program Files\\FlashFXP\\FlashFXP.exe");
}
This one DOES work:
Code:
#include <stdafx.h>
#include <iostream>
using namespace std;
#include <fstream>
int main()
{
system("START C:\\WINDOWS\\notepad.exe");
}
Re: Open file wont work, it says wrong path
The file name (with a space in it) needs to be enclosed in qoutes.
Re: Open file wont work, it says wrong path
Put quotes around your path like so:
Code:
int main()
{
system("START \"C:\\Program Files\\FlashFXP\\FlashFXP.exe\"");
}
sockman
Re: Open file wont work, it says wrong path
Now I get a window that pops up when I execute it instead of it executing the program. Here's a screenshot of what pops up:
http://www.uafclan.com/wolfcry/progr...ileproblem.JPG
Re: Open file wont work, it says wrong path
Quote:
Originally Posted by wolfcry044
Now I get a window that pops up when I execute it instead of it executing the program.
I don't know what you're trying to show us, but what did you expect to happen? If you went to the command line and typed in that start command, what would happen? If it's the same thing as you're seeing now, then that is what you have.
I see the name of the program in the title bar of the command window, so I don't see anything that it shouldn't be doing. To me, the program, FlashFXP.exe *is* running as you've told it to run.
Regards,
Paul McKenzie
Re: Open file wont work, it says wrong path
But it doesn't open the program up or run it. It just opens that window.
When I tell it to open the calculator, it opens it up. But not when I tell it to run anything in program files.
the name is there in the bar because I opened the program myself.
Re: Open file wont work, it says wrong path
The reason the program is running in that screenshot is because I ran it manually, not because that program opened it up. I even tried closing the program and running the .exe again and it still didn't pop any program up. It was just an accident that the flashfxp program was running at the time because I forgot I had manually opened an instance up, the program didn't open it.
Re: Open file wont work, it says wrong path
Isn't it expecting a fillename to play as well?
Try appname.exe /?
to see if they list parameters to supply
Re: Open file wont work, it says wrong path
You still didn't answer my question -- did you type in the "start" command from the command-line? If you did, what results did you get? Is it the same as if you wrote a program and called the "start" command?
Regards,
Paul McKenzie
Re: Open file wont work, it says wrong path
No, when I type it in the start command I get the program popping up. When I execute the program I made I get nothing but a dos window.
Re: Open file wont work, it says wrong path
In fact, the start run command is where I got the url in the first place.