示例#1
0
        /// <summary>
        /// Copies the contents of the given <see cref="IStorageFile"/> into a new file located in the specified <see cref="IStorageFolder"/>, and then removes the source file.
        /// </summary>
        /// <param name="file">The existing file whose contents should be read.</param>
        /// <param name="destination">The destination folder to copy the <see cref="IStorageFile"/> into.</param>
        /// <param name="collisionOptions">Overrides the <see cref="CollisionOptions"/> behavior when creating the new file in the <paramref name="destination"/> folder.</param>
        /// <param name="fileName">Overrides the name of the destination file (default is <see cref="IStorageItem.Name"/> of the source <paramref name="file"/>).</param>
        public static async Task <IStorageFile> MoveToAsync(this IStorageFile file, IStorageFolder destination, CollisionOptions collisionOptions = CollisionOptions.RenameIfExists, string fileName = null)
        {
            IStorageFile destinationFile = await destination.CreateFileAsync(fileName ?? file.Name, collisionOptions);

            await CopyContentsAsync(file, destinationFile);

            await file.RemoveAsync();

            return(destinationFile);
        }