當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudStorageAccount.GetBlobReference方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.CloudStorageAccount.GetBlobReference方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudStorageAccount.GetBlobReference方法的具體用法?C# CloudStorageAccount.GetBlobReference怎麽用?C# CloudStorageAccount.GetBlobReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.CloudStorageAccount的用法示例。


在下文中一共展示了CloudStorageAccount.GetBlobReference方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {
            ServicePointManager.DefaultConnectionLimit = 32;
            var container = new CloudStorageAccount(new StorageCredentialsAccountAndKey(args[1], args[2]), true).CreateCloudBlobClient().GetContainerReference(args[3]);
            container.CreateIfNotExist();

            var cloudHashes = new Dictionary<string, string>();
            foreach (CloudBlob blob in container.ListBlobs(new BlobRequestOptions { UseFlatBlobListing = true }))
            {
                cloudHashes[blob.Uri.ToString().Substring(container.Uri.ToString().Length + 1)] = blob.Properties.ContentMD5;
            }

            var localHashes = new Dictionary<string, string>();
            foreach (var file in Directory.EnumerateFiles(args[0], "*", SearchOption.AllDirectories))
            {
                localHashes[file.Substring(args[0].Length + 1).Replace('\\', '/')] = GetMd5(file);
            }

            foreach (var name in cloudHashes.Keys.Where(n => localHashes.ContainsKey(n) && (localHashes[n] != cloudHashes[n])))
            {
                Console.WriteLine("Uploading {0}", name);
                UploadWithMd5(container, name, Path.Combine(args[0], name));
            }
            foreach (var name in localHashes.Keys.Where(n => !cloudHashes.ContainsKey(n)))
            {
                Console.WriteLine("Uploading {0}", name);
                UploadWithMd5(container, name, Path.Combine(args[0], name));
            }
            foreach (var name in cloudHashes.Keys.Where(n => !localHashes.ContainsKey(n)))
            {
                Console.WriteLine("Deleting {0}", name);
                semaphore.WaitOne();
                var blob = container.GetBlobReference(name);
                Interlocked.Increment(ref count);
                blob.BeginDelete((ar) => {
                    blob.EndDelete(ar);
                    semaphore.Release();
                    Interlocked.Decrement(ref count);
                }, null);
            }

            while (count > 0) Thread.Sleep(TimeSpan.FromSeconds(1));
        }
開發者ID:smarx,項目名稱:SyncToContainer,代碼行數:43,代碼來源:Program.cs


注:本文中的Microsoft.WindowsAzure.CloudStorageAccount.GetBlobReference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。