Quote Originally Posted by 2kaud View Post
using / in a path name may work in some places, but \ is the path separator in windows. And in a non-raw text string, then \\ is used. So

"d://folder//" becomes "d:\\folder" and "d://folder//red//white.txt" becomes ""d:\\folder\\red\\white.txt". If / is used for a path, then you don't use //.



Consider:

Code:
#include <filesystem>

namespace fs = std::filesystem;

const fs::path initpath {"c:\\myprogs\\folder\\"};
const fs::path destname {"c:\\myprogs\\folder\\red\\white.txt"};
const fs::path req_fn {"black.txt"};

int main()
{
	for (const auto& fn : fs::recursive_directory_iterator(initpath))
		if (fs::is_regular_file(fn) && fn.path().filename() == req_fn) {
			fs::copy_file(fn.path(), destname, fs::copy_options::skip_existing);
			break;
		}
}
Your code crashes for me somehow