// </snippet_CreateShareSnapshot> // <snippet_ListShareSnapshots> //------------------------------------------------- // List the snapshots on a share //------------------------------------------------- public void ListShareSnapshots() { // Get the connection string from app settings string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"]; // Instatiate a ShareServiceClient ShareServiceClient shareServiceClient = new ShareServiceClient(connectionString); // Display each share and the snapshots on each share foreach (ShareItem item in shareServiceClient.GetShares(ShareTraits.All, ShareStates.Snapshots)) { if (null != item.Snapshot) { Console.WriteLine($"Share: {item.Name}\tSnapshot: {item.Snapshot}"); } } }
// </snippet_ListShareSnapshots> public ShareItem GetSnapshotItem() { ShareItem result = null; // Get the connection string from app settings string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"]; // Instatiate a ShareServiceClient ShareServiceClient shareServiceClient = new ShareServiceClient(connectionString); foreach (ShareItem item in shareServiceClient.GetShares(ShareTraits.All, ShareStates.Snapshots)) { if (null != item.Snapshot) { // Return the first share with a snapshot return(item); } } return(result); }