---
title: "fileManager(_:shouldLinkItemAtPath:toPath:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filemanagerdelegate/filemanager(_:shouldlinkitematpath:topath:)"
---

# fileManager(_:shouldLinkItemAtPath:toPath:)

Asks the delegate if a hard link should be created between the items at the two paths.

## Declaration

```swift
optional func fileManager(_ fileManager: FileManager, shouldLinkItemAtPath srcPath: String, toPath dstPath: String) -> Bool
```

## Parameters

- `fileManager`: The file manager object that is attempting to create the link.
- `srcPath`: The path or a file or directory that fileManager is about to attempt to link.
- `dstPath`: The path or a file or directory to which fileManager is about to attempt to link.

## Return Value

Return Value true if the operation should proceed, otherwise false.

## Discussion

Discussion If the item specified by destURL is a directory, returning false prevents links from being created to both the directory and its children. This method performs the same task as the fileManager(_:shouldLinkItemAt:to:) method, which is preferred over this method in macOS 10.6 and later.

## See Also

### Related Documentation

- [linkItem(at:to:)](foundation/filemanager/linkitem(at:to:).md)
- [linkItem(atPath:toPath:)](foundation/filemanager/linkitem(atpath:topath:).md)

### Linking an Item

- [fileManager(_:shouldLinkItemAt:to:)](foundation/filemanagerdelegate/filemanager(_:shouldlinkitemat:to:).md)
- [fileManager(_:shouldProceedAfterError:linkingItemAt:to:)](foundation/filemanagerdelegate/filemanager(_:shouldproceedaftererror:linkingitemat:to:).md)
- [fileManager(_:shouldProceedAfterError:linkingItemAtPath:toPath:)](foundation/filemanagerdelegate/filemanager(_:shouldproceedaftererror:linkingitematpath:topath:).md)
