Kernel32CreateHardLink(String, String, IntPtr) Method

Establishes a hard link between an existing file and a new file.

This function is only supported on the NTFS file system, and only for files, not directories.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
public static bool CreateHardLink(
	string dstFilePath,
	string srcFilePath,
	IntPtr reserved = default
)

Parameters

dstFilePath  String
The name of the new file.

This parameter may include the path but cannot specify the name of a directory.

srcFilePath  String
The name of the existing file.

This parameter may include the path cannot specify the name of a directory.

reserved  IntPtr  (Optional)
Reserved; must be Zero.

Return Value

Boolean
If the function succeeds, the return value is .

If the function fails, the return value is .

The maximum number of hard links that can be created with this function is 1023 per file. If more than 1023 links are created for a file, an error results.

To get extended error information, call GetLastWin32Error.

Remarks

See Also