---
title: "fileManager(_:shouldLinkItemAt:to:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filemanagerdelegate/filemanager(_:shouldlinkitemat:to:)"
---

# fileManager(_:shouldLinkItemAt:to:)

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

## Declaration

```swift
optional func fileManager(_ fileManager: FileManager, shouldLinkItemAt srcURL: URL, to dstURL: URL) -> Bool
```

## Parameters

- `fileManager`: The file manager object that is attempting to create the link.
- `srcURL`: The URL identifying the new hard link to be created.
- `dstURL`: The URL identifying the destination of the link.

## Return Value

Return Value true if the link should be created or false if it should not be created.

## 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(_:shouldLinkItemAtPath:toPath:) method and is preferred over that 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(_:shouldLinkItemAtPath:toPath:)](foundation/filemanagerdelegate/filemanager(_:shouldlinkitematpath:topath:).md)
- [fileManager(_:shouldProceedAfterError:linkingItemAt:to:)](foundation/filemanagerdelegate/filemanager(_:shouldproceedaftererror:linkingitemat:to:).md)
- [fileManager(_:shouldProceedAfterError:linkingItemAtPath:toPath:)](foundation/filemanagerdelegate/filemanager(_:shouldproceedaftererror:linkingitematpath:topath:).md)
