<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.5.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSFileManager/removeFileAtPath:handler:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)removeFileAtPath:handler:"
  },
  "title" : "removeFileAtPath:handler:"
}
-->

# removeFileAtPath:handler:

Deletes the file, link, or directory (including, recursively, all subdirectories, files, and links in the directory) identified by a given path.

```
- (BOOL) removeFileAtPath:(NSString *) path handler:(id) handler;
```

## Parameters

`path`

The path of a file, link, or directory to delete. The value must not be “`.`” or “`..`”.

`handler`

An object that responds to the callback messages <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:willProcessPath:)> and <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)>. You can specify `nil` for `handler`; if you do so and an error occurs, the deletion stops and the method automatically returns <doc://com.apple.documentation/documentation/Swift/false>.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the removal operation is successful. If the operation is not successful, but the handler method <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)> returns <doc://com.apple.documentation/documentation/Swift/true>, also returns <doc://com.apple.documentation/documentation/Swift/true>; otherwise returns <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This callback mechanism provided by `handler` is similar to delegation. `NSFileManager` sends <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:willProcessPath:)> when it begins a copy, move, remove, or link operation. It sends <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)> when it encounters any error in processing.

Since the removal of directory contents is so thorough and final, be careful when using this method. If you specify “`.`” or “`..`” for `path` an `NSInvalidArgumentException` exception is raised. This method does not traverse symbolic links.

### Special Considerations

Because this method does not return error information, it has been deprecated as of OS X v10.5. Use [`removeItem(at:)`](/documentation/Foundation/FileManager/removeItem(at:)) instead.

## See Also

[`func linkItem(at: URL, to: URL) throws`](/documentation/Foundation/FileManager/linkItem(at:to:))

Creates a hard link between the items at the specified URLs.

[`func moveItem(atPath: String, toPath: String) throws`](/documentation/Foundation/FileManager/moveItem(atPath:toPath:))

Moves the file or directory at the specified path to a new location synchronously.

[`func copyItem(atPath: String, toPath: String) throws`](/documentation/Foundation/FileManager/copyItem(atPath:toPath:))

Copies the item at the specified path to a new location synchronously.

[`func removeItem(atPath: String) throws`](/documentation/Foundation/FileManager/removeItem(atPath:))

Removes the file or directory at the specified path.



---

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)