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

# fileManager(_:shouldRemoveItemAtPath:)

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

```
optional func fileManager(_ fileManager: FileManager, shouldRemoveItemAtPath path: String) -> Bool
```

## Parameters

`fileManager`

The file manager object that is attempting to remove the file or directory.

`path`

The path to 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 deleted or <doc://com.apple.documentation/documentation/Swift/false> if it should not be deleted.

## 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(_:shouldRemoveItemAt:)`](/documentation/Foundation/FileManagerDelegate/fileManager(_:shouldRemoveItemAt:)) method, which is preferred over this 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)