private void btnEdit_Click(object sender, EventArgs e) { btnEdit.Enabled = false; DirectoryEntry dir = new DirectoryEntry("IIS://localhost/w3svc"); dir.Properties["AspMaxRequestEntityAllowed"].Value = AspMaxRequestEntityAllowed.Text; dir.Properties["DefaultDoc"].Value = DefaultDoc.Text; dir.Properties["LogFileDirectory"].Value = LogFileDirectory.Text; dir.Properties["AspEnableParentPaths"].Value = AspEnableParentPaths.Checked; dir.Properties["ScriptMaps"].Value = Comm.GetScriptMaps(ScriptMaps.Text); dir.CommitChanges(); SET_GZIP(GZIP.Checked, txtGzipPath.Text.Trim()); SetMimeTypeProperty("IIS://localhost/MimeMap", ".flv", "flv-application/octet-stream", FLV.Checked); DirectoryEntry dir2 = new DirectoryEntry("IIS://localhost"); dir2.Properties["EnableEditWhileRunning"].Value = EnableEditWhileRunning.Checked ? "1" : "0"; dir2.CommitChanges(); dir2.Invoke("SaveData", new object[0]);//保存配置到MetaBase.xml //dir2.Invoke("Backup", new object[3]{"haha", 1,1}); //dir2.Invoke("Backup", new object[3] { "haha", 2, 1 }); //dir2.Invoke("Backup", new object[3] { "haha", 3, 2 }); //dir2.Invoke("Backup", new object[3] { "haha2", 1,1 }); //dir2.Invoke("Restore",new object[3] { "haha2", 1,0 }); btnEdit.Enabled = true; MessageBox.Show("OK"); }