<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManagerDelegate/fileManager(_:shouldRemoveItemAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSFileManagerDelegate(im)fileManager:shouldRemoveItemAtURL:"
  },
  "title" : "fileManager(_:shouldRemoveItemAt:)"
}
-->

# fileManager(_:shouldRemoveItemAt:)

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

```
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

<doc://com.apple.documentation/documentation/Swift/true> if the specified item should be removed or <doc://com.apple.documentation/documentation/Swift/false> if it should not be removed.

## Discussion

Removed items are deleted immediately and not placed in the Trash. If the specified item is a directory, returning <doc://com.apple.documentation/documentation/Swift/false> prevents both the directory and its children from being deleted.

This method performs the same task as the [`fileManager(_:shouldRemoveItemAtPath:)`](/documentation/Foundation/FileManagerDelegate/fileManager(_:shouldRemoveItemAtPath:)) method and is preferred over that method in macOS 10.6 and later.

## See Also

[`-  removeItemAtPath:error:`](/documentation/Foundation/FileManager/removeItem(atPath:))

Removes the file or directory at the specified path.

[`-  removeItemAtURL:error:`](/documentation/Foundation/FileManager/removeItem(at:))

Removes the file or directory at the specified URL.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)