简体   繁体   中英

How do I copy a file Or folder in the Program Files folder

How do I copy a file Or folder in the Program Files folder.

Experimented with:

 system("xcopy pro_s\\pro C:\\Program Files  /e /i /h");

But I did not succeed.

Try

system("xcopy \"C:\\Program Files\\foldertocopy\" \"C:\\destination\" /e /i /h"); // Copy from

system("xcopy \"C:\\source\" \"C:\\Program Files\\foldertocopyinto\" /e /i /h"); // Copy to

The latter will need admin rights.

There is a space in "Program Files" which can cause issues. Try surrounding it with double quotes \\"C:\\\\Program Files\\" or try with "C:\\\\Progra~1"

If you are on C++, you can use mighty boost as well: See https://stackoverflow.com/a/2536438 or https://stackoverflow.com/a/8594696 or on windows see SHFileOperation API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM