private void btn_Add_Click(object sender, EventArgs e) { try { if ((txtClassname.Text.Trim() == "") || (txtAssembly.Text.Trim() == "") || (txtName.Text.Trim() == "")) { MessageBox.Show(this, "组件信息不完整,请认真填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string filename = txtFile.Text; if (File.Exists(filename)) { int n = filename.LastIndexOf("\\"); if (n > 1) { string name = filename.Substring(n + 1); if (File.Exists(Application.StartupPath + "\\" + name)) { DialogResult dr = MessageBox.Show("该组件文件已经存在,是否覆盖原组件?", "同名提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { File.Copy(filename, Application.StartupPath + "\\" + name, true); } } else { File.Copy(filename, Application.StartupPath + "\\" + name, true); } } addin.Guid = Guid.NewGuid().ToString().ToUpper(); addin.Classname = txtClassname.Text; addin.Assembly = txtAssembly.Text; addin.Decription = txtDecr.Text; addin.Name = txtName.Text; addin.Version = txtVersion.Text; addin.AddAddIn(); BindlistView(); LoadAddinFile(); MessageBox.Show(this, "组件添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tabControlAddIn.SelectedIndex = 1; } else { MessageBox.Show(this, "所选择的文件不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (System.Exception ex) { MessageBox.Show(this, "组件添加失败!\r\n或者请手工复制该文件至安装目录,并修改配置文件即可。\r\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); LogInfo.WriteLog(ex); } }