Example #1
0
        private void RunDialog_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                //save the launcher configuration to isolated storage
                using (var isoStore = IsolatedStorageFile.GetUserStoreForAssembly())
                {
                    var configFile = new IsolatedStorageFileStream(ConfigFile, FileMode.Create, FileAccess.Write, isoStore);
                    using (var sw = new StreamWriter(configFile))
                    {
                        var launcherType = m_launcher.GetType();
                        //write the concrete type so we know what to deserialize
                        string launcherTypeName = launcherType.AssemblyQualifiedName;
                        sw.WriteLine(launcherTypeName);

                        //write the object itself
                        var serializer = new XmlSerializer(launcherType);
                        serializer.Serialize(sw, m_launcher);
                    }
                    isoStore.Close();
                }
            }
            catch (Exception ex)
            {
                //not catching a problem here will cause the window not to close, which sucks
                MessageBox.Show("Please report a bug: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }