Skip to content

Instantly share code, notes, and snippets.

@donma
Created January 31, 2019 09:49
Show Gist options
  • Save donma/4fd9e7dccd578e11cef5b81bfe3b4b2f to your computer and use it in GitHub Desktop.
Save donma/4fd9e7dccd578e11cef5b81bfe3b4b2f to your computer and use it in GitHub Desktop.
Azure Blob Storage Check File is Existed
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