string or range of characters representing the existing file name
string or range of characters representing the target file name
whether to preserve the file attributes
FileException on error.
auto source = deleteme ~ "source"; auto target = deleteme ~ "target"; auto targetNonExistent = deleteme ~ "target2"; scope(exit) source.remove, target.remove, targetNonExistent.remove; source.write("source"); target.write("target"); assert(target.readText == "target"); source.copy(target); assert(target.readText == "source"); source.copy(targetNonExistent); assert(targetNonExistent.readText == "source");
Copy file from to file to. File timestamps are preserved. File attributes are preserved, if preserve equals Yes.preserveAttributes. On Windows only Yes.preserveAttributes (the default on Windows) is supported. If the target file exists, it is overwritten.