Share via


copy_file Function

Copies the attributes and contents in one file and pastes them in another file.

bool copy_file(const path& Pval1, const path& Pval2, copy_options = copy_options::none);
bool copy_file(const path& Pval1, const path& Pval2, error_code&) noexcept;
bool copy_file(const path& Pval1, const path& Pval2, copy_options Opt, error_code& Err) noexcept;

Parameters

  • Pval1
    The source path.

  • Pval2
    The destination path.

  • Opt
    A copy_option value that specifies function behavior if the destination file already exists. For more information, see copy_option Enumeration <filesystem>.

  • Err
    An error_code value that (on Windows) is returned from GetLastError.

Remarks

Use the copy Function to copy entire directory trees.

Requirements

Header: filesystem

Namespace: std::tr2::sys

See Also

Reference

<filesystem>

Other Resources

C++ Standard Library Header Files