private void GetCloudFiles() { listViewSaves.Items.Clear(); remoteStorage = RemoteStorage.CreateInstance(appID); buttonDelete.IsEnabled = buttonDownload.IsEnabled = buttonUpload.IsEnabled = true; if (!remoteStorage.IsCloudEnabledForAccount) { MessageBox.Show("Steam Cloud is disabled for your account.\nYou need to enable it for this program to work.", "Error"); return; } if (!remoteStorage.IsCloudEnabledForApp) { if (MessageBox.Show("Steam Cloud is disabled for this game.\nYou need to enable it for this program to work.\n\nEnable Steam Cloud for this game?", "Enable Steam Cloud?", MessageBoxButton.YesNo, MessageBoxImage.None) == MessageBoxResult.No) { return; } else { remoteStorage.IsCloudEnabledForApp = true; } } saveFiles = remoteStorage.GetSaves(); for (int i = 0; i < saveFiles.Length; i++) { listViewSaves.Items.Add(saveFiles[i]); } remoteStorage.GetQuota(out ulong spaceMax, out ulong spaceAvaiable); LabelTotalQuota.Content = SaveFile.BytesToString((long)spaceMax); spaceMax /= 1000000; spaceAvaiable /= 1000000; ProgressBarQuota.Maximum = spaceMax; ProgressBarQuota.Value = spaceMax - spaceAvaiable; }
// Method that ensures only one istance at a time can be made public static RemoteStorage CreateInstance(uint appID) { lock (sync) // only one thread at a time can create a new instance; this way we avoid having multiple instances { if (instance != null) { instance.Dispose(); instance = null; } RemoteStorage rs = new RemoteStorage(appID); instance = rs; return(rs); } }