public static AccountManager Load() { var ret = new AccountManager(); using (var store = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null)) { var accountDirs = store.GetDirectoryNames("accounts/*"); foreach (var dir in accountDirs) { try { using (var stream = store.OpenFile("accounts/" + dir + "/settings.xml", FileMode.Open, FileAccess.Read, FileShare.None)) { var serializer = new XmlSerializer(typeof(AccountInfo)); var account = (AccountInfo)serializer.Deserialize(stream); ret.Add(account); } } catch (Exception ex) { ret.OnError(ex); } } } return ret; }
public MainForm() { InitializeComponent(); try { accountManager = AccountManager.Load(); } catch (Exception ex) { accountManager = new AccountManager(); OnError(ex); } fileListView.TaskManager = taskManager; taskListView.TaskManager = taskManager; taskManager.TaskStateChanged += taskManager_TaskStateChanged; taskManager.Exception += xxx_Exception; InitUI(); splitContainer2.SplitterWidth = 7; btnNewConnection.Visible = accountManager.Accounts.Count() == 0; }