public void FetchShareAttributes(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
 {
     try
     {
         Task.Run(() => share.FetchAttributesAsync(accessCondition, options, operationContext)).Wait();
     }
     catch (AggregateException e) when(e.InnerException is StorageException)
     {
         throw e.InnerException;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Manage share metadata
        /// </summary>
        /// <param name="cloudFileClient"></param>
        /// <returns></returns>
        private static async Task ShareMetadataSample(CloudFileClient cloudFileClient)
        {
            Console.WriteLine();
            // Create the share name -- use a guid in the name so it's unique.
            string shareName = "demotest-" + Guid.NewGuid();

            // Create the share with this name.
            CloudFileShare share = cloudFileClient.GetShareReference(shareName);

            // Set share metadata
            Console.WriteLine("Set share metadata");
            share.Metadata.Add("key1", "value1");
            share.Metadata.Add("key2", "value2");

            try
            {
                // Create Share
                Console.WriteLine("Create Share");
                await share.CreateIfNotExistsAsync();

                // Fetch share attributes
                // in this case this call is not need but is included for demo purposes
                await share.FetchAttributesAsync();

                Console.WriteLine("Get share metadata:");
                foreach (var keyValue in share.Metadata)
                {
                    Console.WriteLine("    {0}: {1}", keyValue.Key, keyValue.Value);
                }
                Console.WriteLine();
            }
            catch (StorageException exStorage)
            {
                Common.WriteException(exStorage);
                Console.WriteLine(
                    "Please make sure your storage account is specified correctly in the app.config - then restart the sample.");
                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine("    Exception thrown creating share.");
                Common.WriteException(ex);
                throw;
            }
            finally
            {
                // Delete share
                Console.WriteLine("Delete share");
                share.DeleteIfExists();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Manage share properties
        /// </summary>
        /// <param name="cloudFileClient"></param>
        /// <returns></returns>
        private static async Task SharePropertiesSample(CloudFileClient cloudFileClient)
        {
            Console.WriteLine();
            // Create the share name -- use a guid in the name so it's unique.
            string shareName = "demotest-" + Guid.NewGuid();

            CloudFileShare share = cloudFileClient.GetShareReference(shareName);

            // Set share properties
            Console.WriteLine("Set share properties");
            share.Properties.Quota = 100;

            try
            {
                // Create Share
                Console.WriteLine("Create Share");
                await share.CreateIfNotExistsAsync();

                // Fetch share attributes
                // in this case this call is not need but is included for demo purposes
                await share.FetchAttributesAsync();

                Console.WriteLine("Get share properties:");
                Console.WriteLine("    Quota: {0}", share.Properties.Quota);
                Console.WriteLine("    ETag: {0}", share.Properties.ETag);
                Console.WriteLine("    Last modified: {0}", share.Properties.LastModified);
            }
            catch (StorageException exStorage)
            {
                Common.WriteException(exStorage);
                Console.WriteLine(
                    "Please make sure your storage account is specified correctly in the app.config - then restart the sample.");
                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine("    Exception thrown creating share.");
                Common.WriteException(ex);
                throw;
            }
            finally
            {
                // Delete share
                Console.WriteLine("Delete share");
                share.DeleteIfExists();
            }
            Console.WriteLine();
        }
Ejemplo n.º 4
0
 public Task FetchShareAttributesAsync(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
 {
     return(share.FetchAttributesAsync(accessCondition, options, operationContext, token));
 }
 public void FetchShareAttributes(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
 {
     Task.Run(() => share.FetchAttributesAsync(accessCondition, options, operationContext)).Wait();
 }