【发布时间】:2019-07-19 15:46:34
【问题描述】:
要检查 azure 容器中是否存在单个 blob,我们有以下解决方案,
public bool DoesFileExistsInContainer(string fileName, string containerName)
{
try
{
if (fileName == null)
{
throw new ArgumentException("File name to be moved is empty");
}
CloudBlobContainer containerReference = blobClient.GetContainerReference(containerName);
CloudBlockBlob blob = containerReference.GetBlockBlobReference(fileName);
bool isFileExist = blob.Exists();
return isFileExist;
}
catch (StorageException ex)
{
Logger.LogError("error while checking if blob exists : {0}" + ex);
throw;
}
}
但我想检查 azure 容器中是否存在多个文件?
string[] filesToSearchInBlob = {"file1.xml", "file2.xml", "file3.xml"};
除了在 foreach 循环中之外,还有其他有效的检查方法吗? 使用 LINQ?我们能以更好的方式做到这一点吗?
提前致谢
维努
【问题讨论】:
标签: azure-storage exists not-exists