0

I have a C++ Program that uses the XCOPY DOS command to copy some files.

string command = "xcopy " + source + " " + dest;
const char * cmd = command.c_str();
system(cmd); 

My problem is that this only works when the source file is in the same folder as the EXE. I want to be able to copy X from a child folder.

Does anybody know how i can copy from a source folder without providing the full path (c:\blahh\blahh)? As: xcopy childFolder/filename newname does not work.

I am currently using: xcopy copy.h h.h However does not work for child folders.

Thanks

JP29
  • 633
  • 4
  • 13
  • 25

1 Answers1

0

izomorphius has almost the complete answer in his comment - you should use a back slash. The other issue is you must escape the folder delimiters:

string source = "childfolder\\filename"
dbenham
  • 127,446
  • 28
  • 251
  • 390