replaceItem(at:withItemAt:)
Replaces the item at destinationPath
with the item at existingPath
.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
func replaceItem(at destinationPath: FilePath, withItemAt existingPath: FilePath) async throws
Parameters
- destinationPath
The path of the file or directory to replace.
- existingPath
The path of the existing file or directory.
The following error codes may be thrown:
notFound
if the item atexistingPath
does not exist,io
if the file atexistingPath
was successfully copied todestinationPath
but an error occurred while removing it fromexistingPath.
Note that other errors may also be thrown.
The item at destinationPath
is not required to exist. Note that it is possible to replace a file with a directory and vice versa. After the file or directory at destinationPath
has been replaced, the item at existingPath
will be removed.