/// <summary> /// Moves the current file to the location of the specified file and replaces the specified file in that location. /// </summary> /// <param name="fileToReplace">The file to replace.</param> /// <returns>No object or value is returned by this method.</returns> public Task MoveAndReplaceAsync(IStorageFile fileToReplace) { if (fileToReplace == null) { throw new ArgumentNullException("fileToReplace"); } #if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE return(_file.MoveAndReplaceAsync((Windows.Storage.StorageFile)((StorageFile)fileToReplace)).AsTask()); #elif __ANDROID__ || __UNIFIED__ || WIN32 || TIZEN return(Task.Run(async() => { string fileName = fileToReplace.Name; string folder = global::System.IO.Path.GetDirectoryName(fileToReplace.Path); await fileToReplace.DeleteAsync(); await MoveAsync(await StorageFolder.GetFolderFromPathAsync(folder), fileName); })); #else throw new PlatformNotSupportedException(); #endif }