Example #1
0
        public async Task CloudFileDirectoryWithFilesDeleteAsync()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                await share.CreateAsync();

                if (await CloudFileDirectorySetupAsync(share))
                {
                    CloudFileDirectory dir1    = share.GetRootDirectoryReference().GetDirectoryReference("TopDir1/MidDir1/EndDir1");
                    CloudFile          file1   = dir1.GetFileReference("EndFile1");
                    OperationContext   context = new OperationContext();
                    await TestHelper.ExpectedExceptionAsync(
                        async() => await dir1.DeleteAsync(null, null, context),
                        context,
                        "Delete a non-empty directory",
                        HttpStatusCode.Conflict);

                    await file1.DeleteAsync();

                    await dir1.DeleteAsync();

                    Assert.IsFalse(await file1.ExistsAsync());
                    Assert.IsFalse(await dir1.ExistsAsync());
                }
            }
            finally
            {
                share.DeleteAsync().Wait();
            }
        }
Example #2
0
        public async Task CloudFileDirectoryCreateAndDeleteAsync()
        {
            CloudFileShare share = GetRandomShareReference();
            await share.CreateAsync();

            try
            {
                CloudFileDirectory directory = share.GetRootDirectoryReference().GetDirectoryReference("directory1");
                await directory.CreateAsync();

                Assert.IsTrue(await directory.ExistsAsync());
                await directory.DeleteAsync();

                Assert.IsFalse(await directory.ExistsAsync());
            }
            finally
            {
                share.DeleteAsync().Wait();
            }
        }
 public Task<bool> DirectoryExistsAsync(CloudFileDirectory directory, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return directory.ExistsAsync(options, operationContext, cancellationToken);
 }