---
title: "fileMover(isPresented:files:onCompletion:onCancellation:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/filemover(ispresented:files:oncompletion:oncancellation:)"
---

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

Presents a system dialog for allowing the user to move a collection of existing files to a new location.

## Declaration

```swift
nonisolated func fileMover<C>(isPresented: Binding<Bool>, files: C, onCompletion: @escaping (Result<[URL], any Error>) -> Void, onCancellation: @escaping () -> Void) -> some View where C : Collection, C.Element == URL

```

## Parameters

- `isPresented`: A binding to whether the dialog should be shown.
- `files`: A collection of URLs for the files 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

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 files might look like this:   struct MoveFilesButton: View {       @Binding var files: [URL]       @State private var showFileMover = false       var onCompletion: (URL) -> Void       var onCancellation: (() -> Void)?

var body: some View {           Button {               showFileMover = true           } label: {               Label("Choose destination", systemImage: "folder.circle")           }           .fileMover(isPresented: $showFileMover, files: files) { result in               switch result {               case .success(let urls):                   urls.forEach { url in                       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(_:), fileDialogConfirmationLabel(_:), fileDialogMessage(_:), fileDialogBrowserOptions(_:), fileDialogURLEnabled(_:), fileDialogImportsUnresolvedAliases(_:), and fileDialogCustomizationID(_:).

## See Also

### Moving a file

- [fileMover(isPresented:file:onCompletion:)](swiftui/view/filemover(ispresented:file:oncompletion:).md)
- [fileMover(isPresented:files:onCompletion:)](swiftui/view/filemover(ispresented:files:oncompletion:).md)
- [fileMover(isPresented:file:onCompletion:onCancellation:)](swiftui/view/filemover(ispresented:file:oncompletion:oncancellation:).md)
