/// <summary>
 /// Upload a directory to Azure File Storage.
 /// </summary>
 /// <param name="sourcePath">Path to the source directory</param>
 /// <param name="destFileDir">The <see cref="CloudFileDirectory"/> that is the destination Azure file directory.</param>
 /// <param name="options">An <see cref="UploadDirectoryOptions"/> 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 UploadDirectoryAsync(string sourcePath, CloudFileDirectory destFileDir, UploadDirectoryOptions options, TransferContext context)
 {
     return UploadDirectoryAsync(sourcePath, destFileDir, options, context, CancellationToken.None);
 }
        /// <summary>
        /// Upload a directory to Azure File Storage.
        /// </summary>
        /// <param name="sourcePath">Path to the source directory</param>
        /// <param name="destFileDir">The <see cref="CloudFileDirectory"/> that is the destination Azure file directory.</param>
        /// <param name="options">An <see cref="UploadDirectoryOptions"/> 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 UploadDirectoryAsync(string sourcePath, CloudFileDirectory destFileDir, UploadDirectoryOptions options, TransferContext context, CancellationToken cancellationToken)
        {
            DirectoryLocation sourceLocation = new DirectoryLocation(sourcePath);
            AzureFileDirectoryLocation destLocation = new AzureFileDirectoryLocation(destFileDir);
            FileEnumerator sourceEnumerator = new FileEnumerator(sourceLocation);
            if (options != null)
            {
                sourceEnumerator.SearchPattern = options.SearchPattern;
                sourceEnumerator.Recursive = options.Recursive;
            }

            return UploadDirectoryInternalAsync(sourceLocation, destLocation, sourceEnumerator, options, context, cancellationToken);
        }
        private static Task UploadDirectoryInternalAsync(TransferLocation sourceLocation, TransferLocation destLocation, ITransferEnumerator sourceEnumerator, UploadDirectoryOptions options, TransferContext context, CancellationToken cancellationToken)
        {
            DirectoryTransfer transfer = GetOrCreateDirectoryTransfer(sourceLocation, destLocation, TransferMethod.SyncCopy, context);

            if (transfer.SourceEnumerator == null || !AreSameTransferEnumerators(transfer.SourceEnumerator, sourceEnumerator))
            {
                transfer.SourceEnumerator = sourceEnumerator;
            }

            if (options != null)
            {
                transfer.ContentType = options.ContentType;
                transfer.BlobType = options.BlobType;
            }

            return DoTransfer(transfer, context, cancellationToken);
        }