private void BtnSet_Click(object sender, EventArgs e) { if (lstWorlds.SelectedIndex == -1) { MessageBox.Show("Please select a world first!"); return; } SetWorldName(lstWorlds.Items[lstWorlds.SelectedIndex].ToString()); svp.ServerVars["level-name"].value = lstWorlds.Items[lstWorlds.SelectedIndex].ToString(); File.WriteAllText(svdir + "/server.properties", svp.ToString()); }
private void Save() { var sprop = new ServerProperties(); int p = 0; foreach (TextBox tb in keys) { var stype = sprop.ServerVars[tb.Text].type; TextBox valtext = null; CheckBox valcheck = null; if (stype == 0 || stype == 1) { valtext = (TextBox)values[p]; sprop.ServerVars[tb.Text].value = valtext.Text; } else { valcheck = (CheckBox)values[p]; sprop.ServerVars[tb.Text].value = valcheck.Checked.ToString().ToLower(); } p++; } File.WriteAllText(sPropFile == null ? sPropDir + "/server.properties" : sPropFile, sprop.ToString()); }