Created
January 31, 2019 09:49
-
-
Save donma/4fd9e7dccd578e11cef5b81bfe3b4b2f to your computer and use it in GitHub Desktop.
Azure Blob Storage Check File is Existed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connsctionString = "your_connection_string"; | |
var cloudStorage = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connsctionString); | |
var cloudBlobClient = cloudStorage.CreateCloudBlobClient(); | |
var cloudBlobContainer = cloudBlobClient.GetContainerReference("donmablogsample"); | |
var resultCreateContainer = cloudBlobContainer.CreateIfNotExistsAsync().Result; | |
Console.WriteLine("donmablogsample create already."); | |
Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory cloudBlobDirectory = | |
cloudBlobContainer.GetDirectoryReference("TEST2/TEST21/"); | |
//Existed : true | |
Console.WriteLine("TEST2/TEST21/sampleText1.json is Existed =>" + cloudBlobDirectory.GetBlockBlobReference("sampleText1.json").ExistsAsync().Result); | |
//Existed : false | |
Console.WriteLine("TEST2/TEST21/FileNotExisted.json is Existed =>" + cloudBlobDirectory.GetBlockBlobReference("FileNotExisted.json").ExistsAsync().Result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment