copy function returns The system cannot find the file specified, when the file exists

cmd
11,822

The path of your file has a space in its name, which means you have to surround the path which contains spaces with quotation marks.

Share:
11,822
MinCarve
Author by

MinCarve

I like working with memory and malware

Updated on June 08, 2022

Comments

  • MinCarve
    MinCarve almost 2 years
    copy C:\Users\MinCarve\documents\visual studio 2017\Projects\PROGRAM\Debug\PROGRAM.exe 
         C:\Users
    

    returns

    The system cannot find the file specified. when the executable exists in that directory!

    • Colonel Thirty Two
      Colonel Thirty Two over 6 years
      Probably need quotes around the file name.
    • MinCarve
      MinCarve over 6 years
      how do i add quotes to the directory, if it is a variable in c++?
    • aschipfl
      aschipfl over 6 years
    • MinCarve
      MinCarve over 6 years
      after an hour of digging, i finally did it! string _Loc(Loc); string __Loc = "\"" + _Loc + "\""; system(("copy " + __Loc + " \"C:\\Windows\System32\"").c_str());