/// <summary>
        /// Copy file from an specified URI to an Azure file.
        /// </summary>
        /// <param name="sourceUri">The <see cref="System.Uri"/> of the source file.</param>
        /// <param name="destFile">The <see cref="CloudFile"/> that is the destination Azure file.</param>
        /// <param name="isServiceCopy">A flag indicating whether the copy is service-side asynchronous copy or not.
        /// If this flag is set to true, service-side asychronous copy will be used; if this flag is set to false,
        /// file is downloaded from source first, then uploaded to destination.</param>
        /// <param name="options">A <see cref="CopyOptions"/> object that specifies additional options for the operation.</param>
        /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> object to observe while waiting for a task to complete.</param>
        /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns>
        /// <remarks>Copying from an URI to Azure file synchronously is not supported yet.</remarks>
        public static Task CopyAsync(Uri sourceUri, CloudFile destFile, bool isServiceCopy, CopyOptions options, TransferContext context, CancellationToken cancellationToken)
        {
            if (!isServiceCopy)
            {
                throw new NotSupportedException(Resources.SyncCopyFromUriToAzureFileNotSupportedException);
            }

            TransferLocation sourceLocation = new TransferLocation(sourceUri);
            TransferLocation destLocation = new TransferLocation(destFile);
            return CopyInternalAsync(sourceLocation, destLocation, isServiceCopy, options, context, cancellationToken);
        }
        private static Task CopyInternalAsync(TransferLocation sourceLocation, TransferLocation destLocation, bool isServiceCopy, CopyOptions options, TransferContext context, CancellationToken cancellationToken)
        {
            if (options != null)
            {
                sourceLocation.AccessCondition = options.SourceAccessCondition;
                destLocation.AccessCondition = options.DestinationAccessCondition;
            }

            Transfer transfer = CreateSingleObjectTransfer(sourceLocation, destLocation, isServiceCopy ? TransferMethod.AsyncCopy : TransferMethod.SyncCopy, context);
            return DoTransfer(transfer, cancellationToken);
        }
 /// <summary>
 /// Copy file from an specified URI to an Azure file.
 /// </summary>
 /// <param name="sourceUri">The <see cref="System.Uri"/> of the source file.</param>
 /// <param name="destFile">The <see cref="CloudFile"/> that is the destination Azure file.</param>
 /// <param name="isServiceCopy">A flag indicating whether the copy is service-side asynchronous copy or not.
 /// If this flag is set to true, service-side asychronous copy will be used; if this flag is set to false,
 /// file is downloaded from source first, then uploaded to destination.</param>
 /// <param name="options">A <see cref="CopyOptions"/> object that specifies additional options for the operation.</param>
 /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param>
 /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns>
 /// <remarks>Copying from an URI to Azure file synchronously is not supported yet.</remarks>
 public static Task CopyAsync(Uri sourceUri, CloudFile destFile, bool isServiceCopy, CopyOptions options, TransferContext context)
 {
     return CopyAsync(sourceUri, destFile, isServiceCopy, options, context, CancellationToken.None);
 }
 /// <summary>
 /// Copy content, properties and metadata of an Azure file to another.
 /// </summary>
 /// <param name="sourceFile">The <see cref="CloudFile"/> that is the source Azure file.</param>
 /// <param name="destFile">The <see cref="CloudFile"/> that is the destination Azure file.</param>
 /// <param name="isServiceCopy">A flag indicating whether the copy is service-side asynchronous copy or not.
 /// If this flag is set to true, service-side asychronous copy will be used; if this flag is set to false,
 /// file is downloaded from source first, then uploaded to destination.</param>
 /// <param name="options">A <see cref="CopyOptions"/> object that specifies additional options for the operation.</param>
 /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param>
 /// <param name="cancellationToken">A <see cref="CancellationToken"/> object to observe while waiting for a task to complete.</param>
 /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns>
 public static Task CopyAsync(CloudFile sourceFile, CloudFile destFile, bool isServiceCopy, CopyOptions options, TransferContext context, CancellationToken cancellationToken)
 {
     TransferLocation sourceLocation = new TransferLocation(sourceFile);
     TransferLocation destLocation = new TransferLocation(destFile);
     return CopyInternalAsync(sourceLocation, destLocation, isServiceCopy, options, context, cancellationToken);
 }
 /// <summary>
 /// Copy content, properties and metadata of an Azure file to an Azure blob.
 /// </summary>
 /// <param name="sourceFile">The <see cref="CloudFile"/> that is the source Azure file.</param>
 /// <param name="destBlob">The <see cref="CloudBlob"/> that is the destination Azure blob.</param>
 /// <param name="isServiceCopy">A flag indicating whether the copy is service-side asynchronous copy or not.
 /// If this flag is set to true, service-side asychronous copy will be used; if this flag is set to false,
 /// file is downloaded from source first, then uploaded to destination.</param>
 /// <param name="options">A <see cref="CopyOptions"/> object that specifies additional options for the operation.</param>
 /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param>
 /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns>
 public static Task CopyAsync(CloudFile sourceFile, CloudBlob destBlob, bool isServiceCopy, CopyOptions options, TransferContext context)
 {
     return CopyAsync(sourceFile, destBlob, isServiceCopy, options, context, CancellationToken.None);
 }
        /// <summary>
        /// Copy file from an specified URI to an Azure file.
        /// </summary>
        /// <param name="sourceUri">The <see cref="System.Uri"/> of the source file.</param>
        /// <param name="destFile">The <see cref="CloudFile"/> that is the destination Azure file.</param>
        /// <param name="isServiceCopy">A flag indicating whether the copy is service-side asynchronous copy or not.
        /// If this flag is set to true, service-side asychronous copy will be used; if this flag is set to false,
        /// file is downloaded from source first, then uploaded to destination.</param>
        /// <param name="options">A <see cref="CopyOptions"/> object that specifies additional options for the operation.</param>
        /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> object to observe while waiting for a task to complete.</param>
        /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns>
        /// <remarks>Copying from an URI to Azure file synchronously is not supported yet.</remarks>
        public static Task CopyAsync(Uri sourceUri, CloudFile destFile, bool isServiceCopy, CopyOptions options, TransferContext context, CancellationToken cancellationToken)
        {
            if (!isServiceCopy)
            {
                throw new NotSupportedException(Resources.SyncCopyFromUriToAzureFileNotSupportedException);
            }

            UriLocation sourceLocation = new UriLocation(sourceUri);
            AzureFileLocation destLocation = new AzureFileLocation(destFile);
            if (options != null)
            {
                destLocation.AccessCondition = options.DestinationAccessCondition;
            }

            return CopyInternalAsync(sourceLocation, destLocation, isServiceCopy, context, cancellationToken);
        }
        /// <summary>
        /// Copy content, properties and metadata of an Azure file to another.
        /// </summary>
        /// <param name="sourceFile">The <see cref="CloudFile"/> that is the source Azure file.</param>
        /// <param name="destFile">The <see cref="CloudFile"/> that is the destination Azure file.</param>
        /// <param name="isServiceCopy">A flag indicating whether the copy is service-side asynchronous copy or not.
        /// If this flag is set to true, service-side asychronous copy will be used; if this flag is set to false,
        /// file is downloaded from source first, then uploaded to destination.</param>
        /// <param name="options">A <see cref="CopyOptions"/> object that specifies additional options for the operation.</param>
        /// <param name="context">A <see cref="TransferContext"/> object that represents the context for the current operation.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> object to observe while waiting for a task to complete.</param>
        /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns>
        public static Task CopyAsync(CloudFile sourceFile, CloudFile destFile, bool isServiceCopy, CopyOptions options, TransferContext context, CancellationToken cancellationToken)
        {
            AzureFileLocation sourceLocation = new AzureFileLocation(sourceFile);
            AzureFileLocation destLocation = new AzureFileLocation(destFile);
            if (options != null)
            {
                sourceLocation.AccessCondition = options.SourceAccessCondition;
                destLocation.AccessCondition = options.DestinationAccessCondition;
            }

            return CopyInternalAsync(sourceLocation, destLocation, isServiceCopy, context, cancellationToken);
        }