<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/fileMover(isPresented:file:onCompletion:onCancellation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE9fileMover11isPresented0D012onCompletion0H12CancellationQrAA7BindingVySbG_10Foundation3URLVSgys6ResultOyANs5Error_pGcyyctF"
  },
  "title" : "fileMover(isPresented:file:onCompletion:onCancellation:)"
}
-->

# fileMover(isPresented:file:onCompletion:onCancellation:)

Presents a system dialog for allowing the user to move
an existing file to a new location.

```
nonisolated func fileMover(isPresented: Binding<Bool>, file: URL?, onCompletion: @escaping (Result<URL, any Error>) -> Void, onCancellation: @escaping () -> Void) -> some View
```

## Parameters

`isPresented`

A binding to whether the dialog should be shown.

`file`

The URL of the file to be moved.

`onCompletion`

A callback that will be invoked when the operation has
succeeded or failed. The `result` indicates whether
the operation succeeded or failed. To access the received URLs, call
`startAccessingSecurityScopedResource`.
When the access is no longer required, call `stopAccessingSecurityScopedResource`.

`onCancellation`

A callback that will be invoked
if the user cancels the operation.

## Discussion> Note: This dialog provides security-scoped URLs.
> Call the ``startAccessingSecurityScopedResource`` method to access or bookmark
> the URLs, and the ``stopAccessingSecurityScopedResource`` method
> to release the access.

For example, a button that allows the user to move a file might look like this:

```
  struct MoveFileButton: View {
      @State private var showFileMover = false
      var file: URL
      var onCompletion: (URL) -> Void
      var onCancellation: (() -> Void)?

      var body: some View {
          Button {
              showFileMover = true
          } label: {
              Label("Choose destination", systemImage: "folder.circle")
          }
          .fileMover(isPresented: $showFileMover, file: file) { result in
              switch result {
              case .success(let url):
                  guard url.startAccessingSecurityScopedResource() else {
                      return
                  }
                  onCompletion(url)
                  url.stopAccessingSecurityScopedResource()
              case .failure(let error):
                  print(error)
                  // handle error
              }
          } onCancellation: {
              onCancellation?()
          }
      }
  }
```

To further configure the dialog’s appearance and behavior, use these
view modifiers: [`fileDialogDefaultDirectory(_:)`](/documentation/SwiftUI/View/fileDialogDefaultDirectory(_:)),
[`fileDialogConfirmationLabel(_:)`](/documentation/SwiftUI/View/fileDialogConfirmationLabel(_:)), [`fileDialogMessage(_:)`](/documentation/SwiftUI/View/fileDialogMessage(_:)),
[`fileDialogBrowserOptions(_:)`](/documentation/SwiftUI/View/fileDialogBrowserOptions(_:)), [`fileDialogURLEnabled(_:)`](/documentation/SwiftUI/View/fileDialogURLEnabled(_:)),
[`fileDialogImportsUnresolvedAliases(_:)`](/documentation/SwiftUI/View/fileDialogImportsUnresolvedAliases(_:)), and
[`fileDialogCustomizationID(_:)`](/documentation/SwiftUI/View/fileDialogCustomizationID(_:)).

---

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)