private void apply_btn_Click(object sender, EventArgs e)
        {
            DatabaseSettingsXml ds = new DatabaseSettingsXml();
            ds.DatabaseIpAddress = databaseIpaddress_textBox.Text;
            ds.DatabasePort = Convert.ToInt32(databasePort_textBox.Text);
            ds.DatabaseUser = databaseUser_textBox.Text;
            ds.DatabasePassword = databasePassword_textBox.Text;

            Serialize(ds);
        }
        public static void Deserialize(ref DatabaseSettingsXml databaseSettingsXml)
        {
            if (databaseSettingsXml == null) throw new ArgumentNullException("databaseSettingsXml");
            using (Stream stream = File.Open("settings/databaseSettings.bin", FileMode.Open))
            {
                BinaryFormatter bin = new BinaryFormatter();

                databaseSettingsXml = (DatabaseSettingsXml)bin.Deserialize(stream);
            }
        }
        public static void Serialize(DatabaseSettingsXml databaseSettingsXml)
        {
            if (!Directory.Exists("settings"))
                Directory.CreateDirectory("settings");

            using (Stream stream = File.Open("settings/databaseSettings.bin", FileMode.Create))
            {
                BinaryFormatter bin = new BinaryFormatter();
                bin.Serialize(stream, databaseSettingsXml);
            }
        }
 public DatabaseSettings()
 {
     InitializeComponent();
     if (File.Exists(@"settings/databaseSettings.bin"))
     {
         DatabaseSettingsXml ds = new DatabaseSettingsXml();
         Deserialize(ref ds);
         databaseIpaddress_textBox.Text = ds.DatabaseIpAddress;
         databasePort_textBox.Text = ds.DatabasePort.ToString();
         databaseUser_textBox.Text = ds.DatabaseUser;
         databasePassword_textBox.Text = ds.DatabasePassword;
     }
 }