|
-
November 13th, 2007, 10:33 PM
#1
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");
}
Last edited by wolfcry044; November 13th, 2007 at 10:57 PM.
-
November 14th, 2007, 12:13 AM
#2
Re: Open file wont work, it says wrong path
The file name (with a space in it) needs to be enclosed in qoutes.
Say no to supplying ready made code for homework/work assignments!!
Please rate this post!
-
November 14th, 2007, 12:16 AM
#3
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
-
November 14th, 2007, 02:33 AM
#4
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:
-
November 14th, 2007, 03:50 AM
#5
Re: Open file wont work, it says wrong path
 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
-
November 14th, 2007, 03:51 AM
#6
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.
-
November 14th, 2007, 06:50 PM
#7
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.
-
November 14th, 2007, 06:56 PM
#8
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
-
November 14th, 2007, 06:59 PM
#9
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
-
November 14th, 2007, 07:07 PM
#10
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.
-
November 15th, 2007, 11:45 AM
#11
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|