Search code examples
c++systemxcopy

xcopy command via C++ 'system' not working


I'm trying to copy files from one folder to another via xcopy in my C++ application.

The command outputs : "Invalid number of parameters"

here is the code:

system("xcopy H:\Temp\Configurations C:\temp\TSE /E");

If i try the same command directly in the command prompt, it works perfectly. It just does not work when i call it from my c++ code.


Solution

  • The following works:

    system("\"xcopy H:\\Temp\\Configurations C:\\temp\\TSE\"");
    

    Thanks to @MartinBa

    Explanation here, Thank @Nacho for the link