private SortedDictionary <long, CloudBlob> GetVerBlobs(CloudBlobContainer cloudBlobContainer, IEnumerable <IListBlobItem> blobItems) { SortedDictionary <long, CloudBlob> verBlobs = new SortedDictionary <long, CloudBlob>(); foreach (IListBlobItem blobItem in blobItems) { var blob = cloudBlobContainer.GetBlobReference(blobItem.Uri.ToString()); string name = blob.Name; if (name.Contains(VersionPrefix)) { string version = name.Split(VersionPrefix.ToCharArray()).LastOrDefault(); if (!string.IsNullOrEmpty(version)) { long versionNumber = 0; if (long.TryParse(version.Replace(".", ""), out versionNumber)) { verBlobs.Add(versionNumber, blob); } } } } return(verBlobs); }
public List <string> GetVersions(CloudBlobContainer cloudBlobContainer) { IEnumerable <IListBlobItem> blobItems = cloudBlobContainer.ListBlobs(); SortedDictionary <long, CloudBlob> verBlobs = GetVerBlobs(cloudBlobContainer, blobItems); List <string> versions = new List <string>(); foreach (var blob in verBlobs.Values) { if (blob.Name.Contains(VersionPrefix)) { versions.Add(blob.Name.Split(VersionPrefix.ToCharArray()).LastOrDefault()); } } return(versions); }