void Build() { SaveFileDialog sf = new SaveFileDialog(); sf.AddExtension = true; sf.DefaultExt = "Unv.Package"; if (sf.ShowDialog(this) != DialogResult.OK) { return; } this.Cursor = Cursors.WaitCursor; string filename = sf.FileName; UpdateFileContent[] fcs = new UpdateFileContent[dataGridView1.RowCount]; int i = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { fcs[i] = FileUpdater.GetUpdateFileContent(row.Cells[2].EditedFormattedValue.ToString() + row.Cells[1].EditedFormattedValue.ToString()); fcs[i].ReleasePath = (FileSpecialFolder)Enum.Parse(typeof(FileSpecialFolder), row.Cells[5].EditedFormattedValue.ToString()); fcs[i].RevPath = row.Cells[6].EditedFormattedValue.ToString(); fcs[i].IsReboot = (bool)row.Cells[7].EditedFormattedValue; i++; } string debug = ""; FileUpdater.BuildPackage(fcs, filename, ref debug); #if (DEBUG) { System.IO.File.WriteAllText("c:\\debug.xml", debug); } #endif this.Cursor = Cursors.Default; }
/// <summary> /// 获得UpdateFileContent的基本信息和Content和签名 /// </summary> /// <param name="filename"></param> /// <returns></returns> public static UpdateFileContent GetUpdateFileContent(string filename) { UpdateFileContent f = FileUpdater.GetUpdateFile(filename) as UpdateFileContent; f.Content = System.IO.File.ReadAllBytes(filename); string k = System.Windows.Forms.Application.ProductName + System.Windows.Forms.Application.CompanyName; f.Signa = Core.ShaEnCoder.HashToString(Core.ShaEnCoder.GetHash(f.Content, Encoding.ASCII.GetBytes(k))); return(f); }
void AddFiles() { OpenFileDialog of = new OpenFileDialog(); of.Multiselect = true; if (of.ShowDialog(this) == DialogResult.OK) { foreach (string s in of.FileNames) { UpdateFile fc = FileUpdater.GetUpdateFile(s); int i = dataGridView1.Rows.Add(); dataGridView1[1, i].Value = fc.Name; dataGridView1[2, i].Value = fc.SourcePath; dataGridView1[3, i].Value = fc.FileVersion; dataGridView1[4, i].Value = fc.LastWriteTime.ToString(); dataGridView1[5, i].Value = Enum.GetName(typeof(FileSpecialFolder), FileSpecialFolder.ApplicationStartUpPath); } } }