using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; namespace CreateUpdateXmlFile { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.textBox2.Text = "http://172.28.1.194:7799/AutoUpdate/"; this.textBox3.Text = "ButcherFactory.Login.exe"; } private void view_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) this.textBox1.Text = folderBrowserDialog1.SelectedPath; } private void create_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("请完善信息"); return; } var entity = new ClientVersion(); entity.ServerUrl = textBox2.Text + "ClientVersion.xml"; entity.Version = DateTime.Now.ToString("yyyyMMddHHmm"); var folder = new DirectoryInfo(textBox1.Text); foreach (var file in folder.GetFiles()) { if (file.Name == "ButcherFactory.AutoUpdate.exe") continue; if (file.Extension == ".xml" && file.Name != "ClientVersion.xml") continue; var detail = new UpdateFile(); detail.FileName = file.Name; detail.NeedRestart = textBox3.Text == detail.FileName; detail.Size = (int)file.Length; detail.Url = textBox2.Text + detail.FileName; entity.UpdateFiles.Add(detail); } XmlUtil.SerializerObjToFile(entity); MessageBox.Show("OK"); } } }