How to reload different objects by applicationsettingsbase?
- by younevertell
// TestASettingsString and TestBSettingsString are byte[]
// TestASettings and TestBSettings are two objects to be saved
My question is how to recover TestASettings and TestBSettings from TestASettingsString and TestASettingsString seperately in loadsavedsettings?
Thanks
private void SettingsSaving(object sender, CancelEventArgs e)
{
try
{
var stream = new MemoryStream();
var formatter = new BinaryFormatter();
formatter.Serialize(stream, TestASettings);
// TestASettingsString and TestBSettingsString are byte[]
TestASettingsString = stream.ToArray();
stream.Flush();
formatter.Serialize(stream, TestBSettings);
TestBSettingsString = stream.ToArray();
stream.Close();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
private void LoadSavedSettings()
{
Reload();
// how to get TestASettings and TestBSettings from TestASettingsString and
// TestASettingsString seperately?
}