public override bool DirectoryExists( string path )
{
if ( path == null )
return false;
// Important, when dirPath = "/", the behind HasDirectory(dirPath) will throw exceptions
if ( path == "/" )
return true;
// error check
if (!path.EndsWith(@"/"))
{
Trace.WriteLine(string.Format("Invalid parameter {0} for function IsValidDirectory", path ), "Error");
return false;
}
// remove the first '/' char
string blobDirPath = path.ToAzurePath();
// get reference
CloudBlobDirectory blobDirectory = _container.GetDirectoryReference(blobDirPath);
// non-exist blobDirectory won't contain blobs
if (blobDirectory.ListBlobs().Count() == 0)
return false;
return true;
}