Jump to content
  • Advertisement
Sign in to follow this  
the_regular1

problem using system("move")

This topic is 4734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my c++ program, i'm trying to move a file to docs and setts all users but when I run the program, it says it's an invalid syntax error. I know this is because of the spaces in the dest directory name. I've tried a lot of things but I have had absolutely no luck. could someone please hlep me and maybe post an example so I know how to write it? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Why not just save yourself the trouble and use Win32 methods? Include windows.h
and use

BOOL MoveFile(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName
);


or


BOOL MoveFileEx(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName,
DWORD dwFlags
);

Share this post


Link to post
Share on other sites
Try adding quotes to the command. Like so:

move "filename1" "filename2"

Now, to do that in a system command you will need to use escape characters, so do this (I think):

system ("move /" dir 1 blah blah blah /" /" dir 2 dfsdf dfdf /" ");

That should work.

Share this post


Link to post
Share on other sites
Interesting! Does the Win32's "Move" method pop up that cool window too (the one that comes up when you move things), or do you have to manually code that? Very interesting, I never thought to look in the Win32API for that either. =)

Share this post


Link to post
Share on other sites
Quote:

Interesting! Does the Win32's "Move" method pop up that cool window too (the one that comes up when you move things)

No, it won't. The console window is used to enter MSDOS commands and is used by the routine 'system' to execute the commands you give it (on Windows).
Quote:

system ("move /" dir 1 blah blah blah /" /" dir 2 dfsdf dfdf /" ");

'\' is used to escape characters, so it would actually be:

system ("move \" dir 1 blah blah blah \" \" dir 2 dfsdf dfdf \" ");

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!