copy function returns The system cannot find the file specified, when the file exists
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.
Comments
-
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 over 6 yearsProbably need quotes around the file name.
-
MinCarve over 6 yearshow do i add quotes to the directory, if it is a variable in c++?
-
aschipfl over 6 years
-
MinCarve over 6 yearsafter an hour of digging, i finally did it!
string _Loc(Loc); string __Loc = "\"" + _Loc + "\""; system(("copy " + __Loc + " \"C:\\Windows\System32\"").c_str());
-