Move Operation

Move without Overwrite

Below we will describe the sequence of the move operation.

  1. In the case of the file, the platform opens the file handle and blocks it for reading and writing. The Engine calls IFile.OpenAsync() method. 
  2. The platform starts the move operation. The Engine calls IFileSystemItem.MoveToAsync() method.
  3. The implementer calls IConfirmationResultContext.ReturnConfirmationResult() or IConfirmationResultContext.ReturnErrorResult() with error code.
    • If the ReturnErrorResult() is called the platform displays an error message with Try Again and Cancel buttons. If the user cancels the operation the platform does NOT rename/move. In case of a file, the platform closes the file and the Engine calls IFile.CloseAsync(). The Engine does NOT call IFileSystemItem.MoveToCompletionAsync() and the move operation completes.
    • If the ReturnConfirmationResult() is called the platform moves the item in the file system and marks it as not In-Sync.
  4. If the target is the offline folder, the platform lists the content of the target folder. The Engine calls IFolder.GetChildrenAsync() on the target folder.   
  5. The Engine calls IFileSystemItem.MoveToCompletionAsync() method. Note that it is called for the item in the target path. 
  6. In the case of the file, the Engine calls IFile.CloseAsync() method. 

After the move operation completes, the file or folder is marked as not In-Sync. Depending on how you wish to implement the move operation you can 

Move with Overwrite

In case the target folder exists, the platform requests confirmation from the user for the folder to overwrite. If the user confirms, the following sequence is executed:

  1. The platform starts the source folder deletion. The Engine calls IFileSystemItem.DeleteAsync() for the source folder.
  2. The platform moves each file from the source folder to the target folder. The Engine calls the sequence described in 'Move without Overwrite' section above - OpenAsync() -> MoveToAsync()-> ReturnConfirmationResult() -> MoveToCompletionAsync() -> CloseAsync() method for each file and folder.
  3. The platform completes the delete operation. The Engine calls IFileSystemItem.DeleteCompletionAsync().


Next Article:

Creating Virtual Drive v3