advanced patterns with std::filesystem::copy scenarios on specific file types on Windows 10
I'm experimenting with After trying multiple solutions online, I still can't figure this out. I'm working with an scenario when trying to copy files using `std::filesystem::copy` in C++17 on Windows 10. While it works well for most file types, I'm getting an unexpected behavior when trying to copy `.exe` files. The code I'm using is fairly straightforward: ```cpp #include <filesystem> #include <iostream> int main() { std::filesystem::path source = "C:/path/to/source/file.exe"; std::filesystem::path destination = "C:/path/to/destination/file.exe"; try { std::filesystem::copy(source, destination); std::cout << "File copied successfully!" << std::endl; } catch (const std::filesystem::filesystem_error& e) { std::cerr << "behavior: " << e.what() << std::endl; } return 0; } ``` When I run this code, I receive the following behavior message: `behavior: The process want to access the file because it is being used by another process.` I confirmed that the file isn't open in any application at the time of copying. I also tried running the program as an administrator, but the scenario continues. I’ve tested copying other file types, such as `.txt` and `.jpg`, and those work without any problems. I suspect it might have something to do with file permissions or the way certain executable files are locked by the OS. I've also checked the file attributes using `GetFileAttributes` and everything seems normal. Has anyone else experienced similar issues with `std::filesystem::copy` and `.exe` files on Windows? Any suggestions on how to resolve this question or workarounds would be greatly appreciated. Thanks in advance! I'm working on a API that needs to handle this. For context: I'm using C++ on CentOS.