We recommend using Visual Studio 2017

create_hard_link Function

Creates a hard link to an existing file.

pathpathvoid create_hard_link(
   const path& pval1,
   const path& pval2
void create_hard_link(
   const path& pval1,
   const path& pval2,
   error_code& code
) noexcept;


A path object that represents the file name of an existing file. path can be either a path or a type that is derived from path.


A path object that contains the file name of the hard link.


An error_code object.

The second function returns code.

hard link is the file system representation of a file by which more than one path references a file in the same volume.

If the hard link cannot be created, the first function throws a filesystem_error.

The second function assigns any error code that is associated with the operation to code.

Header: filesystem

Namespace: std::tr2::sys