We have an app that lists files in a folder through Azure Files. When we use the C# method:
Directory.GetFiles(@"\\account.file.core.windows.net\xyz")
It takes around a minute when there are 2000 files.
If we use CloudStorageAccount to do the same:
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
CloudFileDirectory directory = fileClient.GetShareReference("account").GetRootDirectoryReference().GetDirectoryReference("abc");
Int64 totalLength = 0;
foreach (IListFileItem fileAndDirectory in directory.ListFilesAndDirectories())
{
CloudFile file = (CloudFile)fileAndDirectory;
if (file == null) //must be directory if null
continue;
totalLength += file.Properties.Length;
}
It returns all the files, but takes around 10 seconds. Why is there such a large difference in performance?