private void ShowDumpFile(string FileName) { listViewKey.Tag = FileName; listViewKey.Items.Clear(); // listViewKey.FullRowSelect = false; if (!File.Exists(FileName)) { MessageBox.Show("文件不存在!", "错误提示"); return; } try { FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); bool f4k = fs.Length < 4096 ? false : true; byte[] bs = new byte[(f4k ? fs.Length : 4096)]; fs.Read(bs, 0, (int)fs.Length); fs.Close(); string strHex = Common.Common.byteToHexStr(bs); Common.AccessCondition access = new Common.AccessCondition(); for (int i = 0; i < (strHex.Length / 128); i++) { ListViewItem li = new ListViewItem(i.ToString()); li.UseItemStyleForSubItems = true; for (int j = 0; j < 4; j++) { if (j == 3) { li.SubItems.Add(strHex.Substring(i * 128 + j * 32, 12)); access.AccessConditionString = strHex.Substring(i * 128 + j * 32 + 12, 8); li.SubItems.Add(access.AccessConditionString); li.SubItems.Add(strHex.Substring(i * 128 + j * 32 + 20, 12)); } else { li.SubItems.Add(strHex.Substring(i * 128 + j * 32, 32)); } } listViewKey.Items.Add(li); } listViewKey.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); if (!f4k) { if (MessageBox.Show("是否保存为4K文件格式?", "非4K文件格式", MessageBoxButtons.YesNo) == DialogResult.Yes) { SaveDumpFile(FileName); } } } catch (Exception ex) { Common.Log.WriteLog(ex.Message.ToString()); MessageBox.Show("读取文件错误!", "错误提示"); } }
private void ShowDumpFile(string FileName) { listViewKey.Tag=FileName; listViewKey.Items.Clear(); // listViewKey.FullRowSelect = false; if (!File.Exists(FileName)) { MessageBox.Show("文件不存在!", "错误提示"); return; } try { FileStream fs=new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); bool f4k=fs.Length < 4096 ? false : true; byte[] bs=new byte[(f4k ? fs.Length : 4096)]; fs.Read(bs, 0, (int)fs.Length); fs.Close(); string strHex=Common.Common.byteToHexStr(bs); Common.AccessCondition access=new Common.AccessCondition(); for (int i=0; i < (strHex.Length / 128); i++) { ListViewItem li=new ListViewItem(i.ToString()); li.UseItemStyleForSubItems=true; for (int j=0; j < 4; j++) { if (j == 3) { li.SubItems.Add(strHex.Substring(i * 128 + j * 32, 12)); access.AccessConditionString=strHex.Substring(i * 128 + j * 32 + 12, 8); li.SubItems.Add(access.AccessConditionString); li.SubItems.Add(strHex.Substring(i * 128 + j * 32 + 20, 12)); } else { li.SubItems.Add(strHex.Substring(i * 128 + j * 32, 32)); } } listViewKey.Items.Add(li); } listViewKey.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); if (!f4k) { if (MessageBox.Show("是否保存为4K文件格式?", "非4K文件格式", MessageBoxButtons.YesNo) == DialogResult.Yes) { SaveDumpFile(FileName); } } } catch (Exception ex) { Common.Log.WriteLog(ex.Message.ToString()); MessageBox.Show("读取文件错误!", "错误提示"); } }