private void button2_Click(object sender, EventArgs e) { string hostsResult = "IP null"; string selectedIP = null; try { selectedIP = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells["ip"].Value.ToString(); } catch { // } if (selectedIP != null) { hostsResult = Hosts.ChangeHosts("steamcommunity.com", selectedIP); hostsResult = Hosts.ChangeHosts(Hostname, selectedIP); if (hostsResult == "OK") { MessageBox.Show("设置hosts成功!", "SteamHosts"); getCurrentHosts(Hostname); return; } } MessageBox.Show("设置hosts失败,原因:" + hostsResult, "SteamHosts"); }