当前位置: 首页>>代码示例>>C#>>正文


C# CloudBlobContainer.GetDirectoryReference方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.GetDirectoryReference方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.GetDirectoryReference方法的具体用法?C# CloudBlobContainer.GetDirectoryReference怎么用?C# CloudBlobContainer.GetDirectoryReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer的用法示例。


在下文中一共展示了CloudBlobContainer.GetDirectoryReference方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: deleteAll

        public void deleteAll(CloudBlobContainer container, string pathInSyncFolder)
        {
            // update path on server
             pathInSyncFolder = pathInSyncFolder.Replace("\\", "/");

            // check if it is dir
            bool isDir = false;
            CloudBlobDirectory dir = container.GetDirectoryReference(pathInSyncFolder);
            List<IListBlobItem> blobs = dir.ListBlobs().ToList();

            if (blobs.Count != 0)
            {
                isDir = true;
            }

            try
            {

                if (!isDir)
                {
                    // this can only get the blob type, not the dir type
                    var item = container.GetBlobReferenceFromServer(pathInSyncFolder);

                    if (item.GetType() == typeof(CloudBlockBlob))
                    {
                        CloudBlockBlob blob = (CloudBlockBlob)item;
                        blob.DeleteIfExists(DeleteSnapshotsOption.IncludeSnapshots);
                        //blob.Delete();
                        //System.Windows.Forms.MessageBox.Show(string.Format("File: {0} Deleted!", pathInSyncFolder), "DBLike Server");

                    }
                    else if (item.GetType() == typeof(CloudPageBlob))
                    {
                        CloudPageBlob blob = (CloudPageBlob)item;
                        //blob.Delete();
                        blob.DeleteIfExists(DeleteSnapshotsOption.IncludeSnapshots);
                        //System.Windows.Forms.MessageBox.Show(string.Format("File: {0} Deleted!", pathInSyncFolder), "DBLike Server");
                        Program.ServerForm.addtoConsole(string.Format("File: {0} Deleted!", pathInSyncFolder));
                    }
                }
                else
                {
                    // get the directory reference
                    CloudBlobDirectory dira = container.GetDirectoryReference(pathInSyncFolder);
                    deleteFolder(container, dira);
                    //System.Windows.Forms.MessageBox.Show(string.Format("Deleted!\n Folder: {0}", pathInSyncFolder), "DBLike Server");
                    Program.ServerForm.addtoConsole(string.Format("Deleted!\n Folder: {0}", pathInSyncFolder));
                }

            }
            catch
            {
                System.Windows.Forms.MessageBox.Show(string.Format("File: {0} \n doesn't exist!", pathInSyncFolder), "DBLike Server");
                Program.ServerForm.addtoConsole(string.Format("File: {0} \n doesn't exist!", pathInSyncFolder));
            }
        }
开发者ID:hangmiao,项目名称:DBLike,代码行数:56,代码来源:DeleteFile.cs

示例2: LogFolder

        //public String Text;

        public LogFolder(CloudBlobContainer DeploymentContainer, string folder)
        {
            Text = "";

            _server_ref = DeploymentContainer.GetDirectoryReference(folder);

           // Start();

        }
开发者ID:pksorensen,项目名称:C1AzureManager,代码行数:11,代码来源:LogFolder.cs

示例3: AzureBlobContentProvider

        public AzureBlobContentProvider(string connectionString, string basePath, ICacheManager<object> cacheManager)
        {
            _cacheManager = cacheManager;
            var parts = basePath.Split(new[] { "/", "\\" }, StringSplitOptions.RemoveEmptyEntries);

            _containerName = parts.FirstOrDefault();
            _baseDirectoryPath = string.Join("/", parts.Skip(1));

            if (!CloudStorageAccount.TryParse(connectionString, out _cloudStorageAccount))
            {
                throw new InvalidOperationException("Failed to get valid connection string");
            }
            _cloudBlobClient = _cloudStorageAccount.CreateCloudBlobClient();
            _container = _cloudBlobClient.GetContainerReference(_containerName);
            if (_baseDirectoryPath != null)
            {
                _directory = _container.GetDirectoryReference(_baseDirectoryPath);
            }
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:19,代码来源:AzureBlobContentProvider.cs

示例4: CreateCloudBlobDirectoryInstance

        /// <summary>
        /// Creates a <see cref="CloudBlobDirectory"/> object using the specified account credentials.
        /// </summary>
        /// <param name="credentials">A <see cref="StorageCredentials"/> object.</param>
        private void CreateCloudBlobDirectoryInstance(StorageCredentials credentials)
        {
            if (null == this.containerUri)
            {
                throw new InvalidOperationException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.ParameterCannotBeNullException,
                        "containerUri"));
            }

            CloudBlobContainer container = new CloudBlobContainer(this.containerUri, credentials);
            this.blobDir = container.GetDirectoryReference(this.relativeAddress);
        }
开发者ID:ggais,项目名称:azure-storage-net-data-movement,代码行数:18,代码来源:SerializableCloudBlobDirectory.cs

示例5: BlobTypesWithStorageUri

        public void BlobTypesWithStorageUri()
        {
            StorageUri endpoint = new StorageUri(
                new Uri("http://" + AccountName + BlobService + EndpointSuffix),
                new Uri("http://" + AccountName + SecondarySuffix + BlobService + EndpointSuffix));

            CloudBlobClient client = new CloudBlobClient(endpoint, new StorageCredentials());
            Assert.IsTrue(endpoint.Equals(client.StorageUri));
            Assert.IsTrue(endpoint.PrimaryUri.Equals(client.BaseUri));

            StorageUri containerUri = new StorageUri(
                new Uri(endpoint.PrimaryUri + "container"),
                new Uri(endpoint.SecondaryUri + "container"));

            CloudBlobContainer container = client.GetContainerReference("container");
            Assert.IsTrue(containerUri.Equals(container.StorageUri));
            Assert.IsTrue(containerUri.PrimaryUri.Equals(container.Uri));
            Assert.IsTrue(endpoint.Equals(container.ServiceClient.StorageUri));

            container = new CloudBlobContainer(containerUri, client.Credentials);
            Assert.IsTrue(containerUri.Equals(container.StorageUri));
            Assert.IsTrue(containerUri.PrimaryUri.Equals(container.Uri));
            Assert.IsTrue(endpoint.Equals(container.ServiceClient.StorageUri));

            StorageUri directoryUri = new StorageUri(
                new Uri(containerUri.PrimaryUri + "/directory/"),
                new Uri(containerUri.SecondaryUri + "/directory/"));

            StorageUri subdirectoryUri = new StorageUri(
                new Uri(directoryUri.PrimaryUri + "subdirectory/"),
                new Uri(directoryUri.SecondaryUri + "subdirectory/"));

            CloudBlobDirectory directory = container.GetDirectoryReference("directory");
            Assert.IsTrue(directoryUri.Equals(directory.StorageUri));
            Assert.IsTrue(directoryUri.PrimaryUri.Equals(directory.Uri));
            Assert.IsNotNull(directory.Parent);
            Assert.IsTrue(containerUri.Equals(directory.Container.StorageUri));
            Assert.IsTrue(endpoint.Equals(directory.ServiceClient.StorageUri));

            CloudBlobDirectory subdirectory = directory.GetDirectoryReference("subdirectory");
            Assert.IsTrue(subdirectoryUri.Equals(subdirectory.StorageUri));
            Assert.IsTrue(subdirectoryUri.PrimaryUri.Equals(subdirectory.Uri));
            Assert.IsTrue(directoryUri.Equals(subdirectory.Parent.StorageUri));
            Assert.IsTrue(containerUri.Equals(subdirectory.Container.StorageUri));
            Assert.IsTrue(endpoint.Equals(subdirectory.ServiceClient.StorageUri));

            StorageUri blobUri = new StorageUri(
                new Uri(subdirectoryUri.PrimaryUri + "blob"),
                new Uri(subdirectoryUri.SecondaryUri + "blob"));

            CloudBlockBlob blockBlob = subdirectory.GetBlockBlobReference("blob");
            Assert.IsTrue(blobUri.Equals(blockBlob.StorageUri));
            Assert.IsTrue(blobUri.PrimaryUri.Equals(blockBlob.Uri));
            Assert.IsTrue(subdirectoryUri.Equals(blockBlob.Parent.StorageUri));
            Assert.IsTrue(containerUri.Equals(blockBlob.Container.StorageUri));
            Assert.IsTrue(endpoint.Equals(blockBlob.ServiceClient.StorageUri));

            blockBlob = new CloudBlockBlob(blobUri, null, client.Credentials);
            Assert.IsTrue(blobUri.Equals(blockBlob.StorageUri));
            Assert.IsTrue(blobUri.PrimaryUri.Equals(blockBlob.Uri));
            Assert.IsTrue(subdirectoryUri.Equals(blockBlob.Parent.StorageUri));
            Assert.IsTrue(containerUri.Equals(blockBlob.Container.StorageUri));
            Assert.IsTrue(endpoint.Equals(blockBlob.ServiceClient.StorageUri));

            CloudPageBlob pageBlob = subdirectory.GetPageBlobReference("blob");
            Assert.IsTrue(blobUri.Equals(pageBlob.StorageUri));
            Assert.IsTrue(blobUri.PrimaryUri.Equals(pageBlob.Uri));
            Assert.IsTrue(subdirectoryUri.Equals(pageBlob.Parent.StorageUri));
            Assert.IsTrue(containerUri.Equals(pageBlob.Container.StorageUri));
            Assert.IsTrue(endpoint.Equals(pageBlob.ServiceClient.StorageUri));

            pageBlob = new CloudPageBlob(blobUri, null, client.Credentials);
            Assert.IsTrue(blobUri.Equals(pageBlob.StorageUri));
            Assert.IsTrue(blobUri.PrimaryUri.Equals(pageBlob.Uri));
            Assert.IsTrue(subdirectoryUri.Equals(pageBlob.Parent.StorageUri));
            Assert.IsTrue(containerUri.Equals(pageBlob.Container.StorageUri));
            Assert.IsTrue(endpoint.Equals(pageBlob.ServiceClient.StorageUri));
        }
开发者ID:DaC24,项目名称:azure-storage-net,代码行数:78,代码来源:StorageUriTests.cs

示例6: GetBlobNamesForDirectory

 internal List<string> GetBlobNamesForDirectory(CloudBlobContainer container, string directoryName)
 {
     var folder = container.GetDirectoryReference(directoryName);
     var blobs = folder.ListBlobs(true);
     var blobNames = new List<string>();
     foreach (var item in blobs)
     {
         if (item.GetType() == typeof(CloudBlockBlob))
         {
             var blob = (CloudBlockBlob)item;
             var blobNameParts = blob.Name.Split('/');
             blobNames.Add(blobNameParts[blobNameParts.Length-1]);
         }
         else if (item.GetType() == typeof(CloudPageBlob))
         {
             var pageBlob = (CloudPageBlob)item;
             var blobNameParts = pageBlob.Name.Split('/');
             blobNames.Add(blobNameParts[blobNameParts.Length - 1]);
         }
     }
     return blobNames;
 }
开发者ID:jobeland,项目名称:DistributedNetworkTrainingStorage,代码行数:22,代码来源:AzureBlobProxy.cs

示例7: CreateNonEmptyDirectory

 private async Task CreateNonEmptyDirectory(CloudBlobContainer container, string directoryName)
 {
     var dir = container.GetDirectoryReference(directoryName);
     var blob = dir.GetBlockBlobReference("blob");
     await CreateEmptyBlob(blob);
 }
开发者ID:ReubenBond,项目名称:Yams,代码行数:6,代码来源:AzureBlobContainerTest.cs

示例8: GetSubDirectories

        /// <summary>
        /// Get All users active directory users List 
        /// </summary>
        /// <param name="container"></param>
        /// <returns></returns>
        public static Dictionary<string, string> GetSubDirectories(CloudBlobContainer container, string Prepend, string append, string subContainerName)
        {
            Dictionary<string, string> result = new Dictionary<string, string>();
            try
            {
                var directory = container.GetDirectoryReference(@subContainerName);
                var folders = directory.ListBlobs().Where(b => b as CloudBlobDirectory != null).ToList();
                foreach (var folder in folders)
                {
                    string userName = folder.Uri.AbsolutePath.Replace(folder.Parent.Uri.AbsolutePath, "").Trim('/');
                    string userPath = Prepend + userName + append;

                    var blob = container.GetBlockBlobReference(userPath);
                    if (blob.Exists())
                    {
                        result.Add(userName, userPath);
                    }

                    //result.Add(userName, userPath);
                }
            }
            catch (Exception exception)
            {
                return result;
            }
            return result;
        }
开发者ID:Rollins,项目名称:OrkinPriceApp,代码行数:32,代码来源:BlobHelper.cs


注:本文中的Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.GetDirectoryReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。