---
title: "fileManager(_:shouldRemoveItemAt:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filemanagerdelegate/filemanager(_:shouldremoveitemat:)"
---

# fileManager(_:shouldRemoveItemAt:)

Asks the delegate whether the item at the specified URL should be deleted.

## Declaration

```swift
optional func fileManager(_ fileManager: FileManager, shouldRemoveItemAt URL: URL) -> Bool
```

## Parameters

- `fileManager`: The file manager object that is attempting to remove the file or directory.
- `URL`: The URL indicating the file or directory that the file manager is attempting to delete.

## Return Value

Return Value true if the specified item should be removed or false if it should not be removed.

## Discussion

Discussion Removed items are deleted immediately and not placed in the Trash. If the specified item is a directory, returning false prevents both the directory and its children from being deleted. This method performs the same task as the fileManager(_:shouldRemoveItemAtPath:) method and is preferred over that method in macOS 10.6 and later.

## See Also

### Related Documentation

- [removeItem(atPath:)](foundation/filemanager/removeitem(atpath:).md)
- [removeItem(at:)](foundation/filemanager/removeitem(at:).md)

### Removing an Item

- [fileManager(_:shouldRemoveItemAtPath:)](foundation/filemanagerdelegate/filemanager(_:shouldremoveitematpath:).md)
- [fileManager(_:shouldProceedAfterError:removingItemAt:)](foundation/filemanagerdelegate/filemanager(_:shouldproceedaftererror:removingitemat:).md)
- [fileManager(_:shouldProceedAfterError:removingItemAtPath:)](foundation/filemanagerdelegate/filemanager(_:shouldproceedaftererror:removingitematpath:).md)
