public static Task<IFile> CopyAsync( this IFile file, IFolder destinationFolder ) { Arg.NotNull( file, nameof( file ) ); Arg.NotNull( destinationFolder, nameof( destinationFolder ) ); Contract.Ensures( Contract.Result<Task<IFile>>() != null ); return file.CopyAsync( destinationFolder, file.Name ); }
static async Task<IFile> CopyDirectoryAsync (this IFileSystem src, IFile file, IFileSystem dest, string destDir) { var newPath = await dest.GetAvailableNameAsync (Path.Combine (destDir, Path.GetFileName (file.Path))); var r = await dest.CreateDirectory (newPath); if (!r) throw new Exception ("Failed to create destination directory " + newPath + " on " + dest); var srcFiles = await src.ListFiles (file.Path); foreach (var f in srcFiles) { await src.CopyAsync (f, dest, newPath); } try { return await dest.GetFile (newPath); } catch (Exception ex) { Log.Error (ex); return null; } }
public static Task<IFile> DuplicateAsync (this IFileSystem fs, IFile file) { return fs.CopyAsync (file, fs, Path.GetDirectoryName (file.Path)); }
/// <summary> /// Copy user disk from one collection to the other and keep the source /// user disk. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.RemoteApp.IUserDiskOperations. /// </param> /// <param name='srcCollectionName'> /// Required. The source collection name. /// </param> /// <param name='dstCollectionName'> /// Required. The destination collection name. /// </param> /// <param name='userUpn'> /// Required. The user upn. /// </param> /// <param name='overwriteExistingUserDisk'> /// Required. A flag denoting if the request is to overwrite the /// existing user disk /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<AzureOperationResponse> CopyAsync(this IUserDiskOperations operations, string srcCollectionName, string dstCollectionName, string userUpn, bool overwriteExistingUserDisk) { return operations.CopyAsync(srcCollectionName, dstCollectionName, userUpn, overwriteExistingUserDisk, CancellationToken.None); }