C/C++ Copy file with automatic recursive folder/directory creation

前端 未结 2 1336
野性不改
野性不改 2020-12-17 03:15

In Win32 API, there is CopyFile that literally copies a file. However, this API doesn\'t create folders. For example, I\'d like to copy C:\\Data\\output.txt to

2条回答
  •  清歌不尽
    2020-12-17 04:20

    SHFileOperation should do the trick. From MSDN:

    Copy and Move operations can specify destination directories that do not exist. In those cases, the system attempts to create them and normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags.

提交回复
热议问题