//********************** //* * //* AddAccount_Click * //* * //********************** // Display dialog for adding a storage account. private async void AddAccount_Click(object sender, RoutedEventArgs e) { AccountDialog dlg = new AccountDialog(); dlg.Title = "Add Storage Account"; dlg.IsEdit = false; if (dlg.ShowDialog().Value) { String accountName = dlg.AccountName.Text; AzureAccount account = new AzureAccount() { IsDeveloperAccount = dlg.AccountTypeDev.IsChecked.Value, Name = dlg.AccountName.Text, Key = dlg.AccountKey.Text, UseSSL = dlg.UseSSL, EndpointDomain = dlg.EndpointDomain.Text.Trim() }; if (String.IsNullOrEmpty(account.EndpointDomain)) { account.EndpointDomain = "core.windows.net"; } if (account.IsDeveloperAccount) { account.Name = "DevStorage"; } Accounts.Add(account); SaveAccountList(); DisplayAccountList(); await AddStorageViewAsync(accountName); } }
//********************* //* * //* LoadAccountList * //* * //********************* // Load the account list combo box. private void LoadAccountList() { String filename = System.Windows.Forms.Application.UserAppDataPath + "\\AzureStorageExplorer6.dt1"; Accounts.Clear(); if (File.Exists(filename)) { using (TextReader reader = File.OpenText(filename)) { reader.ReadLine(); // version String line; String[] items; while ((line = reader.ReadLine()) != null) { try { line = StringCipher.Decrypt(line, cipherKey); items = line.Split('|'); if (items.Length >= 4) { AzureAccount account = new AzureAccount() { Name = items[0], Key = items[1], IsDeveloperAccount = (items[2] == "1"), UseSSL = (items[3] == "1") }; if (items.Length >= 5) { account.EndpointDomain = items[4]; } else { account.EndpointDomain = "core.windows.net"; } Accounts.Add(account); } } catch (Exception) { // If something is wrong in the account data file, don't let that stop the rest from loading. } } } } }