C#二进制文件编程实践
生活随笔
收集整理的這篇文章主要介紹了
C#二进制文件编程实践
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
C#讀寫二進(jìn)制文件
http://www.cnblogs.com/top5/archive/2011/02/07/1949675.html本文要介紹的C#本地讀寫二進(jìn)制文件,二進(jìn)制文件指保存在物理磁盤的一個文件。
第一步:讀寫文件轉(zhuǎn)成流對象。其實就是讀寫文件流 (FileStream對象,在System.IO命名空間中)。File、FileInfo、FileStream這三個類可以將打開文件,并變成文件 流。下面是引用微軟對File、FileInfo、FileStream的介紹
System.IO.File類 提供用于創(chuàng)建、復(fù)制、刪除、移動和打開文件的靜態(tài)方法,并協(xié)助創(chuàng)建 FileStream 對象。
System.IO.FileInfo類 提供創(chuàng)建、復(fù)制、刪除、移動和打開文件的實例方法,并且?guī)椭鷦?chuàng)建 FileStream 對象。無法繼承此類。
System.IO.FileStream類 公開以文件為主的 Stream,既支持同步讀寫操作,也支持異步讀寫操作。
我直接使用 FileStream,他繼承于Stream
第二步:讀寫流。讀寫二進(jìn)制文件用System.IO.BinaryReader和System.IO.BinaryWriter類;讀寫文本文件用System.IO.TextReader和System.IO.TextWriter類。下面是我的實體 (即要保持到文件的數(shù)據(jù))
? /// <summary>
?/// 學(xué)生基本信息類
?/// </summary>
?public class Student
?{
? /// <summary>
? /// 學(xué)號變量
? /// </summary>
? private String _id;
? /// <summary>
? /// 姓名變量
? /// </summary>
? private String _name;
? /// <summary>
? /// 語文成績變量
? /// </summary>
? private Double _score1;
? /// <summary>
? /// 數(shù)學(xué)成績變量
? /// </summary>
? private Double _score2;
? /// <summary>
? /// 英語成績變量
? /// </summary>
? private Double _score3;
? /// <summary>
? /// 學(xué)號屬性
? /// </summary>
? public String Id
? {
? ?get { return _id; }
? ?set { _id = value; }
? }
? /// <summary>
? /// 姓名屬性
? /// </summary>
? public String Name
? {
? ?get { return _name; }
? ?set { _name = value; }
? }
? /// <summary>
? /// 語文成績屬性
? /// </summary>
? public Double Score1
? {
? ?get { return _score1; }
? ?set { _score1 = value; }
? }
? /// <summary>
? /// 數(shù)學(xué)成績屬性
? /// </summary>
? public Double Score2
? {
? ?get { return _score2; }
? ?set { _score2 = value; }
? }
? /// <summary>
? /// 英語成績屬性
? /// </summary>
? public Double Score3
? {
? ?get { return _score3; }
? ?set { _score3 = value; }
? }
?}
?下面是我的讀方法,讀取文件中的信息到參數(shù)List<Student> stu中 ?
? /// <summary>
? /// 讀取信息方法
? /// </summary>
? /// <returns>讀取是否成功</returns>
? public void ReadInfo(List<Student> stu)
? {
? ?Console.WriteLine("請輸入文件讀取路徑:(鍵入回車為默認(rèn)路徑)");
? ?String filename = Console.ReadLine();
? ?FileStream fs;
? ?//默認(rèn)路徑
? ?if (filename == "")
? ?{
? ? fs = new FileStream("student.dll", FileMode.Open);
? ?}
? ?else
? ?{
? ? //如果文件不存在,就提示錯誤
? ? if (!File.Exists(filename))
? ? {
? ? ?Console.WriteLine("\n\t讀取失敗!\n錯誤原因:可能不存在此文件");
? ? ?return;
? ? }
? ? //否則創(chuàng)建文件
? ? fs = new FileStream(filename, FileMode.Open);
? ?}
? ?//使用二進(jìn)制讀取
? ?BinaryReader br = new BinaryReader(fs);
? ?Console.Write("讀取信息將覆蓋現(xiàn)有的信息,繼續(xù)嗎?y/n :");
? ?String command = Console.ReadLine();
? ?if (command == "y" || command == "Y")
? ?{
? ? for (int i = 0; i < stu.Count; i++)
? ? {
? ? ?stu.RemoveAt(i);
? ? }
? ? //從磁盤上讀取信息
? ? try
? ? {
? ? ?while (true)
? ? ?{
? ? ? Student student = new Student();
? ? ? student.Id = br.ReadString();
? ? ? student.Name = br.ReadString();
? ? ? student.Score1 = br.ReadDouble();
? ? ? student.Score2 = br.ReadDouble();
? ? ? student.Score3 = br.ReadDouble();
? ? ? stu.Add(student);
? ? ? student = null;
? ? ?}
? ? }
? ? catch (Exception)
? ? {
? ? ?Console.WriteLine("\n\n讀取結(jié)束!");
? ? }
? ?}
? ?br.Close();
? ?fs.Close();
? }
下面是我的寫入方法,寫入?yún)?shù)List<Student> stu中的數(shù)據(jù)
? /// <summary>
? /// 寫入信息方法
? /// </summary>
? /// <returns>寫入是否成功</returns>
? public void WriteInfo(List<Student> stu)
? {
? ?Console.WriteLine("請輸入文件保存路徑:(鍵入回車為默認(rèn)路徑)");
? ?FileStream fs;
? ?String filename = Console.ReadLine();
? ?//默認(rèn)路徑
? ?if (filename == "")
? ?{
? ? fs = new FileStream("student.dll", FileMode.Create);
? ?}
? ?//手動輸入路徑
? ?else
? ?{
? ? //如果文件存在,就提示錯誤
? ? if (File.Exists(filename))
? ? {
? ? ?Console.WriteLine("\n\t保存失敗!\n錯誤原因:可能存在相同文件");
? ? ?return;
? ? }
? ? //否則創(chuàng)建文件
? ? fs = new FileStream(filename, FileMode.Create);
? ?}
? ?//數(shù)據(jù)保存到磁盤中
? ?BinaryWriter bw = new BinaryWriter(fs);
? ?foreach (Student student in stu)
? ?{
? ? bw.Write((String)student.Id);
? ? bw.Write((String)student.Name);
? ? bw.Write((Double)student.Score1);
? ? bw.Write((Double)student.Score2);
? ? bw.Write((Double)student.Score3);
? ? bw.Flush();
? ?}
? ?bw.Close();
? ?fs.Close();
? ?Console.WriteLine("保存成功!");
? }
========
C#二進(jìn)制文件比較程序
http://blog.csdn.net/foart/article/details/7031577轉(zhuǎn):http://www.cnblogs.com/hbhbice/archive/2010/06/30/1768477.html
下面是CompareFile.cs
[csharp] view plain copy print?
using System; ?
?using System.Collections.Generic; ?
?using System.Text; ?
?using System.IO; ?
?using System.Windows.Forms; ?
?using System.Data; ?
? ?
?namespace CompareFile ?
?{ ?
? ? ?public ?class FileCompare ?
? ? ?{ ?
? ? ? ? ?private FileStream fs1, fs2; ?
? ? ? ? ?private DataTable _DiffTab1,_DiffTab2; ?
? ?
? ? ? ? ?public DataTable DiffTab1 ?
? ? ? ? ?{ ?
? ? ? ? ? ? ?get { ?
? ? ? ? ? ? ? ? ?return _DiffTab1; ?
? ? ? ? ? ? ?} ?
? ? ? ? ?} ?
? ?
? ? ? ? ?public DataTable DiffTab2 ?
? ? ? ? ?{ ?
? ? ? ? ? ? ?get ?
? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ?return _DiffTab2; ?
? ? ? ? ? ? ?} ?
? ? ? ? ?} ?
? ?
? ? ? ? ?public FileCompare(FileStream fs1, FileStream fs2) ?
? ? ? ? ?{ ?
? ? ? ? ? ? ?this.fs1 = fs1; ?
? ? ? ? ? ? ?this.fs2 = fs2; ?
? ? ? ? ?} ?
? ?
? ? ? ? ?public void CompareAllFile() ?
? ? ? ? ?{ ?
? ? ? ? ? ? ?if (fs1 .Length !=fs2.Length ) ?
? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ?if (MessageBox.Show("兩文件長度不等\r\n文件1長:" + fs1.Length.ToString() + "\r\n文件2長:" + fs2.Length.ToString() + "\r\n是否繼續(xù)比較?", "文件比較結(jié)果") == DialogResult.Cancel ) ?
? ? ? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ? ? ?return; ?
? ? ? ? ? ? ? ? ?} ?
? ? ? ? ? ? ?} ?
? ? ? ? ? ? ?BinaryReader br1 = new BinaryReader (fs1 ); ?
? ? ? ? ? ? ?BinaryReader br2 = new BinaryReader (fs2); ?
? ? ? ? ? ? ?long min = fs1.Length >= fs2.Length ? fs2.Length : fs1.Length; ?
? ? ? ? ? ? ?for (long i = 0; i <min ? ; i++) ?
? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ?if ( br1 .ReadByte ()!=br2 .ReadByte ()) ?
? ? ? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ? ? ?if (MessageBox.Show("從0起,第" + (br1.BaseStream.Position - 1).ToString() + "個字節(jié)不匹配" + "是否繼續(xù)搜尋?", "文件比較",MessageBoxButtons.OKCancel) == DialogResult.OK) ?
? ? ? ? ? ? ? ? ? ? ?{ ?
? ?
? ? ? ? ? ? ? ? ? ? ?} ?
? ? ? ? ? ? ? ? ? ? ?else ??
? ? ? ? ? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ? ? ? ? ?br1.BaseStream.Seek((br1.BaseStream.Position / 50) * 50, 0); ?
? ? ? ? ? ? ? ? ? ? ? ? ?br2.BaseStream.Seek((br1.BaseStream.Position / 50) * 50, 0); ?
? ? ? ? ? ? ? ? ? ? ? ? ?if (br1 .BaseStream .Length - br1 .BaseStream .Position >50&&br2 .BaseStream .Length - br2 .BaseStream .Position >50) ?
? ? ? ? ? ? ? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_DiffTab1 = new DataTable(); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_DiffTab2 = new DataTable(); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DataColumn dc1 = new DataColumn("位置"); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DataColumn dc2 = new DataColumn("數(shù)值"); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DataColumn dc3 = new DataColumn("位置"); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DataColumn dc4 = new DataColumn("數(shù)值"); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_DiffTab1.Columns.Add(dc1); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_DiffTab1.Columns.Add(dc2); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_DiffTab2.Columns.Add(dc3); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_DiffTab2.Columns.Add(dc4); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?for (int j = 0; j < 50; j++) ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DataRow dr1 = _DiffTab1.NewRow(); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dr1[0] = br1.BaseStream.Position; ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dr1[1] = br1.ReadByte(); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DiffTab1.Rows.Add(dr1); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DataRow dr2 = _DiffTab2.NewRow(); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dr2[0] = br2.BaseStream.Position; ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dr2[1] = br2.ReadByte(); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DiffTab2.Rows.Add(dr2); ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} ?
? ? ? ? ? ? ? ? ? ? ? ? ?} ?
? ? ? ? ? ? ? ? ? ? ? ? ?return; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ?} ? ?
? ?
? ? ? ? ? ? ? ? ?} ?
? ? ? ? ? ? ? ? ?if (fs1.Position == min ) ?
? ? ? ? ? ? ? ? ?{ ?
? ? ? ? ? ? ? ? ? ? ?MessageBox.Show("到達(dá)兩文件中較小文件的尾部"); ?
? ? ? ? ? ? ? ? ?} ?
? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ? ??
? ?
? ? ? ? ?} ?
? ? ?} ?
?} ?
Form1.cs
[csharp] view plain copy print?
using System; ?
using System.Collections.Generic; ?
using System.ComponentModel; ?
using System.Data; ?
using System.Drawing; ?
using System.Text; ?
using System.Windows.Forms; ?
using System.IO; ?
??
namespace CompareFile ?
{ ?
? ? public partial class Form1 : Form ?
? ? { ?
? ? ? ? FileStream fs1; ?
? ? ? ? FileStream fs2; ?
??
? ? ? ? public Form1() ?
? ? ? ? { ?
? ? ? ? ? ? InitializeComponent(); ?
? ? ? ? } ?
??
? ? ? ? private void 打開OToolStripMenuItem_Click(object sender, EventArgs e) ?
? ? ? ? { ?
? ? ? ? ? ? if (openFileDialog1 .ShowDialog ()== DialogResult .OK ) ?
? ? ? ? ? ? { ?
? ? ? ? ? ? ? ? fs1 = (FileStream )openFileDialog1.OpenFile(); ?
? ? ? ? ? ? } ?
? ? ? ? } ?
??
? ? ? ? private void 保存SToolStripMenuItem_Click(object sender, EventArgs e) ?
? ? ? ? { ?
? ? ? ? ? ? if (openFileDialog1.ShowDialog ()== DialogResult .OK ) ?
? ? ? ? ? ? { ?
? ? ? ? ? ? ? ? fs2 = (FileStream )openFileDialog1.OpenFile(); ?
? ? ? ? ? ? } ?
? ? ? ? } ?
??
? ? ? ? private void 自定義CToolStripMenuItem_Click(object sender, EventArgs e) ?
? ? ? ? { ?
? ? ? ? ? ? if (fs1 != null && fs2 != null) ?
? ? ? ? ? ? { ?
? ? ? ? ? ? ? ? CompareFile.FileCompare fc = new CompareFile.FileCompare(fs1, fs2); ?
? ? ? ? ? ? ? ? fc.CompareAllFile(); ?
? ? ? ? ? ? ? ? dataGridView1.DataSource = fc.DiffTab1; ?
? ? ? ? ? ? ? ? dataGridView2.DataSource = fc.DiffTab2; ?
? ? ? ? ? ? } ?
? ? ? ? ? ? else ?
? ? ? ? ? ? { ?
? ? ? ? ? ? ? ? MessageBox.Show ("請先將兩個文件打開,然后再進(jìn)行比較!"); ?
? ? ? ? ? ? } ?
??
? ? ? ? } ?
??
? ? ? ? private void 另存為AToolStripMenuItem_Click(object sender, EventArgs e) ?
? ? ? ? { ?
? ? ? ? ? ? fs1.Close(); ?
? ? ? ? ? ? fs2.Close(); ?
??
? ? ? ? } ? ?
? ? } ?
} ?
Form1.Designer.cs(如果界面方面不清楚,參考以下代碼。)
[csharp] view plain copy print?
namespace CompareFile ?
{ ?
? ? partial class Form1 ?
? ? { ?
? ? ? ? /// <summary> ?
? ? ? ? /// 必需的設(shè)計器變量。 ?
? ? ? ? /// </summary> ?
? ? ? ? private System.ComponentModel.IContainer components = null; ?
??
? ? ? ? /// <summary> ?
? ? ? ? /// 清理所有正在使用的資源。 ?
? ? ? ? /// </summary> ?
? ? ? ? /// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param> ?
? ? ? ? protected override void Dispose(bool disposing) ?
? ? ? ? { ?
? ? ? ? ? ? if (disposing && (components != null)) ?
? ? ? ? ? ? { ?
? ? ? ? ? ? ? ? components.Dispose(); ?
? ? ? ? ? ? } ?
? ? ? ? ? ? base.Dispose(disposing); ?
? ? ? ? } ?
?
? ? ? ? #region Windows 窗體設(shè)計器生成的代碼 ?
??
? ? ? ? /// <summary> ?
? ? ? ? /// 設(shè)計器支持所需的方法 - 不要 ?
? ? ? ? /// 使用代碼編輯器修改此方法的內(nèi)容。 ?
? ? ? ? /// </summary> ?
? ? ? ? private void InitializeComponent() ?
? ? ? ? { ?
? ? ? ? ? ? System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); ?
? ? ? ? ? ? this.menuStrip1 = new System.Windows.Forms.MenuStrip(); ?
? ? ? ? ? ? this.文件FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.新建NToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.打開OToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.保存SToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); ?
? ? ? ? ? ? this.另存為AToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); ?
? ? ? ? ? ? this.打印PToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.打印預(yù)覽VToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); ?
? ? ? ? ? ? this.退出XToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.編輯EToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.撤消UToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.重復(fù)RToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); ?
? ? ? ? ? ? this.剪切TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.粘貼PToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); ?
? ? ? ? ? ? this.全選AToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.工具TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.自定義CToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.選項OToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.幫助HToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.內(nèi)容CToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.索引IToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.搜索SToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); ?
? ? ? ? ? ? this.關(guān)于AToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ?
? ? ? ? ? ? this.splitContainer1 = new System.Windows.Forms.SplitContainer(); ?
? ? ? ? ? ? this.dataGridView1 = new System.Windows.Forms.DataGridView(); ?
? ? ? ? ? ? this.dataGridView2 = new System.Windows.Forms.DataGridView(); ?
? ? ? ? ? ? this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); ?
? ? ? ? ? ? this.toolStrip1 = new System.Windows.Forms.ToolStrip(); ?
? ? ? ? ? ? this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); ?
? ? ? ? ? ? this.menuStrip1.SuspendLayout(); ?
? ? ? ? ? ? this.splitContainer1.Panel1.SuspendLayout(); ?
? ? ? ? ? ? this.splitContainer1.Panel2.SuspendLayout(); ?
? ? ? ? ? ? this.splitContainer1.SuspendLayout(); ?
? ? ? ? ? ? ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ?
? ? ? ? ? ? ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); ?
? ? ? ? ? ? this.toolStrip1.SuspendLayout(); ?
? ? ? ? ? ? this.SuspendLayout(); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // menuStrip1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { ?
? ? ? ? ? ? this.文件FToolStripMenuItem, ?
? ? ? ? ? ? this.編輯EToolStripMenuItem, ?
? ? ? ? ? ? this.工具TToolStripMenuItem, ?
? ? ? ? ? ? this.幫助HToolStripMenuItem}); ?
? ? ? ? ? ? this.menuStrip1.Location = new System.Drawing.Point(0, 0); ?
? ? ? ? ? ? this.menuStrip1.Name = "menuStrip1"; ?
? ? ? ? ? ? this.menuStrip1.Size = new System.Drawing.Size(676, 24); ?
? ? ? ? ? ? this.menuStrip1.TabIndex = 0; ?
? ? ? ? ? ? this.menuStrip1.Text = "menuStrip1"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 文件FToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.文件FToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { ?
? ? ? ? ? ? this.新建NToolStripMenuItem, ?
? ? ? ? ? ? this.打開OToolStripMenuItem, ?
? ? ? ? ? ? this.保存SToolStripMenuItem, ?
? ? ? ? ? ? this.toolStripSeparator, ?
? ? ? ? ? ? this.另存為AToolStripMenuItem, ?
? ? ? ? ? ? this.toolStripSeparator1, ?
? ? ? ? ? ? this.打印PToolStripMenuItem, ?
? ? ? ? ? ? this.打印預(yù)覽VToolStripMenuItem, ?
? ? ? ? ? ? this.toolStripSeparator2, ?
? ? ? ? ? ? this.退出XToolStripMenuItem}); ?
? ? ? ? ? ? this.文件FToolStripMenuItem.Name = "文件FToolStripMenuItem"; ?
? ? ? ? ? ? this.文件FToolStripMenuItem.Size = new System.Drawing.Size(59, 20); ?
? ? ? ? ? ? this.文件FToolStripMenuItem.Text = "文件(&F)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 新建NToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.新建NToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("新建NToolStripMenuItem.Image"))); ?
? ? ? ? ? ? this.新建NToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.新建NToolStripMenuItem.Name = "新建NToolStripMenuItem"; ?
? ? ? ? ? ? this.新建NToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); ?
? ? ? ? ? ? this.新建NToolStripMenuItem.Size = new System.Drawing.Size(190, 22); ?
? ? ? ? ? ? this.新建NToolStripMenuItem.Text = "新建(&N)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 打開OToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.打開OToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("打開OToolStripMenuItem.Image"))); ?
? ? ? ? ? ? this.打開OToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.打開OToolStripMenuItem.Name = "打開OToolStripMenuItem"; ?
? ? ? ? ? ? this.打開OToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); ?
? ? ? ? ? ? this.打開OToolStripMenuItem.Size = new System.Drawing.Size(190, 22); ?
? ? ? ? ? ? this.打開OToolStripMenuItem.Text = "打開文件1(&O)"; ?
? ? ? ? ? ? this.打開OToolStripMenuItem.Click += new System.EventHandler(this.打開OToolStripMenuItem_Click); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 保存SToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.保存SToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.保存SToolStripMenuItem.Name = "保存SToolStripMenuItem"; ?
? ? ? ? ? ? this.保存SToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); ?
? ? ? ? ? ? this.保存SToolStripMenuItem.Size = new System.Drawing.Size(190, 22); ?
? ? ? ? ? ? this.保存SToolStripMenuItem.Text = "打開文件2(&S)"; ?
? ? ? ? ? ? this.保存SToolStripMenuItem.Click += new System.EventHandler(this.保存SToolStripMenuItem_Click); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStripSeparator ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStripSeparator.Name = "toolStripSeparator"; ?
? ? ? ? ? ? this.toolStripSeparator.Size = new System.Drawing.Size(187, 6); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 另存為AToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.另存為AToolStripMenuItem.Name = "另存為AToolStripMenuItem"; ?
? ? ? ? ? ? this.另存為AToolStripMenuItem.Size = new System.Drawing.Size(190, 22); ?
? ? ? ? ? ? this.另存為AToolStripMenuItem.Text = "關(guān)閉兩文件(&A)"; ?
? ? ? ? ? ? this.另存為AToolStripMenuItem.Click += new System.EventHandler(this.另存為AToolStripMenuItem_Click); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStripSeparator1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStripSeparator1.Name = "toolStripSeparator1"; ?
? ? ? ? ? ? this.toolStripSeparator1.Size = new System.Drawing.Size(187, 6); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 打印PToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.打印PToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("打印PToolStripMenuItem.Image"))); ?
? ? ? ? ? ? this.打印PToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.打印PToolStripMenuItem.Name = "打印PToolStripMenuItem"; ?
? ? ? ? ? ? this.打印PToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P))); ?
? ? ? ? ? ? this.打印PToolStripMenuItem.Size = new System.Drawing.Size(190, 22); ?
? ? ? ? ? ? this.打印PToolStripMenuItem.Text = "打印(&P)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 打印預(yù)覽VToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.打印預(yù)覽VToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("打印預(yù)覽VToolStripMenuItem.Image"))); ?
? ? ? ? ? ? this.打印預(yù)覽VToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.打印預(yù)覽VToolStripMenuItem.Name = "打印預(yù)覽VToolStripMenuItem"; ?
? ? ? ? ? ? this.打印預(yù)覽VToolStripMenuItem.Size = new System.Drawing.Size(190, 22); ?
? ? ? ? ? ? this.打印預(yù)覽VToolStripMenuItem.Text = "打印預(yù)覽(&V)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStripSeparator2 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStripSeparator2.Name = "toolStripSeparator2"; ?
? ? ? ? ? ? this.toolStripSeparator2.Size = new System.Drawing.Size(187, 6); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 退出XToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.退出XToolStripMenuItem.Name = "退出XToolStripMenuItem"; ?
? ? ? ? ? ? this.退出XToolStripMenuItem.Size = new System.Drawing.Size(190, 22); ?
? ? ? ? ? ? this.退出XToolStripMenuItem.Text = "退出(&X)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 編輯EToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.編輯EToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { ?
? ? ? ? ? ? this.撤消UToolStripMenuItem, ?
? ? ? ? ? ? this.重復(fù)RToolStripMenuItem, ?
? ? ? ? ? ? this.toolStripSeparator3, ?
? ? ? ? ? ? this.剪切TToolStripMenuItem, ?
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem, ?
? ? ? ? ? ? this.粘貼PToolStripMenuItem, ?
? ? ? ? ? ? this.toolStripSeparator4, ?
? ? ? ? ? ? this.全選AToolStripMenuItem}); ?
? ? ? ? ? ? this.編輯EToolStripMenuItem.Name = "編輯EToolStripMenuItem"; ?
? ? ? ? ? ? this.編輯EToolStripMenuItem.Size = new System.Drawing.Size(60, 20); ?
? ? ? ? ? ? this.編輯EToolStripMenuItem.Text = "編輯(&E)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 撤消UToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.撤消UToolStripMenuItem.Name = "撤消UToolStripMenuItem"; ?
? ? ? ? ? ? this.撤消UToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); ?
? ? ? ? ? ? this.撤消UToolStripMenuItem.Size = new System.Drawing.Size(156, 22); ?
? ? ? ? ? ? this.撤消UToolStripMenuItem.Text = "撤消(&U)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 重復(fù)RToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.重復(fù)RToolStripMenuItem.Name = "重復(fù)RToolStripMenuItem"; ?
? ? ? ? ? ? this.重復(fù)RToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); ?
? ? ? ? ? ? this.重復(fù)RToolStripMenuItem.Size = new System.Drawing.Size(156, 22); ?
? ? ? ? ? ? this.重復(fù)RToolStripMenuItem.Text = "重復(fù)(&R)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStripSeparator3 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStripSeparator3.Name = "toolStripSeparator3"; ?
? ? ? ? ? ? this.toolStripSeparator3.Size = new System.Drawing.Size(153, 6); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 剪切TToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.剪切TToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("剪切TToolStripMenuItem.Image"))); ?
? ? ? ? ? ? this.剪切TToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.剪切TToolStripMenuItem.Name = "剪切TToolStripMenuItem"; ?
? ? ? ? ? ? this.剪切TToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); ?
? ? ? ? ? ? this.剪切TToolStripMenuItem.Size = new System.Drawing.Size(156, 22); ?
? ? ? ? ? ? this.剪切TToolStripMenuItem.Text = "剪切(&T)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 復(fù)制CToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("復(fù)制CToolStripMenuItem.Image"))); ?
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem.Name = "復(fù)制CToolStripMenuItem"; ?
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); ?
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem.Size = new System.Drawing.Size(156, 22); ?
? ? ? ? ? ? this.復(fù)制CToolStripMenuItem.Text = "復(fù)制(&C)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 粘貼PToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.粘貼PToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("粘貼PToolStripMenuItem.Image"))); ?
? ? ? ? ? ? this.粘貼PToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.粘貼PToolStripMenuItem.Name = "粘貼PToolStripMenuItem"; ?
? ? ? ? ? ? this.粘貼PToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); ?
? ? ? ? ? ? this.粘貼PToolStripMenuItem.Size = new System.Drawing.Size(156, 22); ?
? ? ? ? ? ? this.粘貼PToolStripMenuItem.Text = "粘貼(&P)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStripSeparator4 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStripSeparator4.Name = "toolStripSeparator4"; ?
? ? ? ? ? ? this.toolStripSeparator4.Size = new System.Drawing.Size(153, 6); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 全選AToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.全選AToolStripMenuItem.Name = "全選AToolStripMenuItem"; ?
? ? ? ? ? ? this.全選AToolStripMenuItem.Size = new System.Drawing.Size(156, 22); ?
? ? ? ? ? ? this.全選AToolStripMenuItem.Text = "全選(&A)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 工具TToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.工具TToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { ?
? ? ? ? ? ? this.自定義CToolStripMenuItem, ?
? ? ? ? ? ? this.選項OToolStripMenuItem}); ?
? ? ? ? ? ? this.工具TToolStripMenuItem.Name = "工具TToolStripMenuItem"; ?
? ? ? ? ? ? this.工具TToolStripMenuItem.Size = new System.Drawing.Size(61, 20); ?
? ? ? ? ? ? this.工具TToolStripMenuItem.Text = "工具(&T)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 自定義CToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.自定義CToolStripMenuItem.Name = "自定義CToolStripMenuItem"; ?
? ? ? ? ? ? this.自定義CToolStripMenuItem.Size = new System.Drawing.Size(117, 22); ?
? ? ? ? ? ? this.自定義CToolStripMenuItem.Text = "比較(&C)"; ?
? ? ? ? ? ? this.自定義CToolStripMenuItem.Click += new System.EventHandler(this.自定義CToolStripMenuItem_Click); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 選項OToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.選項OToolStripMenuItem.Name = "選項OToolStripMenuItem"; ?
? ? ? ? ? ? this.選項OToolStripMenuItem.Size = new System.Drawing.Size(117, 22); ?
? ? ? ? ? ? this.選項OToolStripMenuItem.Text = "選項(&O)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 幫助HToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.幫助HToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { ?
? ? ? ? ? ? this.內(nèi)容CToolStripMenuItem, ?
? ? ? ? ? ? this.索引IToolStripMenuItem, ?
? ? ? ? ? ? this.搜索SToolStripMenuItem, ?
? ? ? ? ? ? this.toolStripSeparator5, ?
? ? ? ? ? ? this.關(guān)于AToolStripMenuItem}); ?
? ? ? ? ? ? this.幫助HToolStripMenuItem.Name = "幫助HToolStripMenuItem"; ?
? ? ? ? ? ? this.幫助HToolStripMenuItem.Size = new System.Drawing.Size(61, 20); ?
? ? ? ? ? ? this.幫助HToolStripMenuItem.Text = "幫助(&H)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 內(nèi)容CToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.內(nèi)容CToolStripMenuItem.Name = "內(nèi)容CToolStripMenuItem"; ?
? ? ? ? ? ? this.內(nèi)容CToolStripMenuItem.Size = new System.Drawing.Size(128, 22); ?
? ? ? ? ? ? this.內(nèi)容CToolStripMenuItem.Text = "內(nèi)容(&C)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 索引IToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.索引IToolStripMenuItem.Name = "索引IToolStripMenuItem"; ?
? ? ? ? ? ? this.索引IToolStripMenuItem.Size = new System.Drawing.Size(128, 22); ?
? ? ? ? ? ? this.索引IToolStripMenuItem.Text = "索引(&I)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 搜索SToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.搜索SToolStripMenuItem.Name = "搜索SToolStripMenuItem"; ?
? ? ? ? ? ? this.搜索SToolStripMenuItem.Size = new System.Drawing.Size(128, 22); ?
? ? ? ? ? ? this.搜索SToolStripMenuItem.Text = "搜索(&S)"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStripSeparator5 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStripSeparator5.Name = "toolStripSeparator5"; ?
? ? ? ? ? ? this.toolStripSeparator5.Size = new System.Drawing.Size(125, 6); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // 關(guān)于AToolStripMenuItem ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.關(guān)于AToolStripMenuItem.Name = "關(guān)于AToolStripMenuItem"; ?
? ? ? ? ? ? this.關(guān)于AToolStripMenuItem.Size = new System.Drawing.Size(128, 22); ?
? ? ? ? ? ? this.關(guān)于AToolStripMenuItem.Text = "關(guān)于(&A)..."; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // splitContainer1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; ?
? ? ? ? ? ? this.splitContainer1.Location = new System.Drawing.Point(0, 24); ?
? ? ? ? ? ? this.splitContainer1.Name = "splitContainer1"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // splitContainer1.Panel1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.splitContainer1.Panel1.Controls.Add(this.dataGridView1); ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // splitContainer1.Panel2 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.splitContainer1.Panel2.Controls.Add(this.dataGridView2); ?
? ? ? ? ? ? this.splitContainer1.Size = new System.Drawing.Size(676, 528); ?
? ? ? ? ? ? this.splitContainer1.SplitterDistance = 326; ?
? ? ? ? ? ? this.splitContainer1.TabIndex = 1; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // dataGridView1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; ?
? ? ? ? ? ? this.dataGridView1.Location = new System.Drawing.Point(0, 28); ?
? ? ? ? ? ? this.dataGridView1.Name = "dataGridView1"; ?
? ? ? ? ? ? this.dataGridView1.RowTemplate.Height = 23; ?
? ? ? ? ? ? this.dataGridView1.Size = new System.Drawing.Size(326, 500); ?
? ? ? ? ? ? this.dataGridView1.TabIndex = 0; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // dataGridView2 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; ?
? ? ? ? ? ? this.dataGridView2.Location = new System.Drawing.Point(0, 28); ?
? ? ? ? ? ? this.dataGridView2.Name = "dataGridView2"; ?
? ? ? ? ? ? this.dataGridView2.RowTemplate.Height = 23; ?
? ? ? ? ? ? this.dataGridView2.Size = new System.Drawing.Size(346, 500); ?
? ? ? ? ? ? this.dataGridView2.TabIndex = 0; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // openFileDialog1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.openFileDialog1.FileName = "openFileDialog1"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStrip1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { ?
? ? ? ? ? ? this.toolStripButton1}); ?
? ? ? ? ? ? this.toolStrip1.Location = new System.Drawing.Point(0, 24); ?
? ? ? ? ? ? this.toolStrip1.Name = "toolStrip1"; ?
? ? ? ? ? ? this.toolStrip1.Size = new System.Drawing.Size(676, 25); ?
? ? ? ? ? ? this.toolStrip1.TabIndex = 2; ?
? ? ? ? ? ? this.toolStrip1.Text = "toolStrip1"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // toolStripButton1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; ?
? ? ? ? ? ? this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); ?
? ? ? ? ? ? this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; ?
? ? ? ? ? ? this.toolStripButton1.Name = "toolStripButton1"; ?
? ? ? ? ? ? this.toolStripButton1.Size = new System.Drawing.Size(23, 22); ?
? ? ? ? ? ? this.toolStripButton1.Text = "toolStripButton1"; ?
? ? ? ? ? ? // ??
? ? ? ? ? ? // Form1 ?
? ? ? ? ? ? // ??
? ? ? ? ? ? this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); ?
? ? ? ? ? ? this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ?
? ? ? ? ? ? this.ClientSize = new System.Drawing.Size(676, 552); ?
? ? ? ? ? ? this.Controls.Add(this.toolStrip1); ?
? ? ? ? ? ? this.Controls.Add(this.splitContainer1); ?
? ? ? ? ? ? this.Controls.Add(this.menuStrip1); ?
? ? ? ? ? ? this.MainMenuStrip = this.menuStrip1; ?
? ? ? ? ? ? this.Name = "Form1"; ?
? ? ? ? ? ? this.Text = "Form1"; ?
? ? ? ? ? ? this.menuStrip1.ResumeLayout(false); ?
? ? ? ? ? ? this.menuStrip1.PerformLayout(); ?
? ? ? ? ? ? this.splitContainer1.Panel1.ResumeLayout(false); ?
? ? ? ? ? ? this.splitContainer1.Panel2.ResumeLayout(false); ?
? ? ? ? ? ? this.splitContainer1.ResumeLayout(false); ?
? ? ? ? ? ? ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); ?
? ? ? ? ? ? ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); ?
? ? ? ? ? ? this.toolStrip1.ResumeLayout(false); ?
? ? ? ? ? ? this.toolStrip1.PerformLayout(); ?
? ? ? ? ? ? this.ResumeLayout(false); ?
? ? ? ? ? ? this.PerformLayout(); ?
??
? ? ? ? } ?
?
? ? ? ? #endregion ?
??
? ? ? ? private System.Windows.Forms.MenuStrip menuStrip1; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 文件FToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 新建NToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 打開OToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripSeparator toolStripSeparator; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 保存SToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 另存為AToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 打印PToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 打印預(yù)覽VToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 退出XToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 編輯EToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 撤消UToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 重復(fù)RToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 剪切TToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 復(fù)制CToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 粘貼PToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 全選AToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 工具TToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 自定義CToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 選項OToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 幫助HToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 內(nèi)容CToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 索引IToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 搜索SToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; ?
? ? ? ? private System.Windows.Forms.ToolStripMenuItem 關(guān)于AToolStripMenuItem; ?
? ? ? ? private System.Windows.Forms.SplitContainer splitContainer1; ?
? ? ? ? private System.Windows.Forms.OpenFileDialog openFileDialog1; ?
? ? ? ? private System.Windows.Forms.DataGridView dataGridView1; ?
? ? ? ? private System.Windows.Forms.DataGridView dataGridView2; ?
? ? ? ? private System.Windows.Forms.ToolStrip toolStrip1; ?
? ? ? ? private System.Windows.Forms.ToolStripButton toolStripButton1; ? ?
? ? } ?
} ?
========
C# Parsing 類實現(xiàn)的 PDF 文件分析器
https://www.oschina.net/translate/pdf-file-analyzer-with-csharp-parsing-classes-vers下載示例
下載源代碼
1. 介紹
這個項目讓你可以去讀取并解析一個PDF文件,并將其內(nèi)部結(jié)構(gòu)展示出來. PDF文件的格式標(biāo)準(zhǔn)文檔可以從Adobe那兒獲取到. 這個項目基于“PDF指南,第六版,Adobe便攜文檔格式1.7 2006年11月”. 它是一個恐怕有1310頁的大部頭. 本文提供了對這份文檔的簡潔概述. 與此相關(guān)的項目定義了用來讀取和解析PDF文件的C#類. 為了測試這些類,附帶的測試程序PdfFileAnalyzer讓你可以去讀取一個PDF文件,分析它并展示和保存結(jié)果. 程序?qū)DF文件分割成單獨每頁的描述,字體,圖片和其它對象. 有兩種類型的PDF文件不受此程序的支持: 加密文件和多代文件.
這個程序的1.1版本允許世界各地使用點符號作為小數(shù)分隔符的程序員來編譯和運行程序.
1.2版本則修復(fù)了一個有關(guān)使用跨多個引用流來讀取PDF文檔的問題. 1.2之前的版本對此場景只會以一個對象數(shù)字重復(fù)的錯誤而終止運行.
如果你對將PDF文件寫入器引入你的應(yīng)用程序,那就請讀一讀 "PDF 文件寫入程序 C# 類庫" 這篇文章吧.
PDF格式的文件,借助Adobe Acrobat軟件,可以在各種屏幕上顯示查看,使用各種打印機(jī)打印。但是,如果使用二進(jìn)制文件編輯器打開PDF文件,你會發(fā)現(xiàn)文件的大部分是不可讀的,有小部分是可讀的,如下:
1 0 obj
<</Lang(en-CA)/MarkInfo<</Marked true>>/Pages 2 0 R
/StructTreeRoot 10 0 R/Type/Catalog>>
endobj
2 0 obj
<</Count 1/Kids[4 0 R]/Type/Pages>>
endobj?
4 0 obj
<</Contents 5 0 R/Group <</CS/DeviceRGB /S/Transparency /Type/Group>>
/MediaBox[0 0 612 792] /Parent 2 0 R
/Resources <</Font <</F1 6 0 R /F2 8 0 R>>
/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>
/StructParents 0/Tabs/S/Type/Page>>
endobj
5 0 obj
<</Filter/FlateDecode/Length 2319>>
stream
. . .
endstream
endobj
看上去,該文件是由嵌套在“n 0 OBJ ”和“ endobj ”關(guān)鍵詞之間的對象組成的,術(shù)語PDF也就是間接對象的意思。 “obj”前面的數(shù)字是對象編號和第幾代對象標(biāo)識, 雙尖括號中的內(nèi)容表示數(shù)據(jù)字典對象,中括號中的內(nèi)容表示數(shù)組對象, 以斜杠/ 開始的內(nèi)容表示參數(shù)名稱 (例如: /Pages)。上例中的第一項 “1 0 obj” 表示文檔的目錄或者文檔的根對象。文檔目錄的字典對象 “/Pages 2 0 R”,指向定義頁碼樹對象的引用。按照這樣推算,編號為2的對象包含指向 “/Kids[4 0 R]”的頁面的引用,是一個頁面文檔。 編號為4的對象是唯一的一個頁面定義, 頁面大小為612*792點, 換句話說,也就是8.5” * 11” (1” 代表72 點)點。該頁面使用了兩種字體F1和F2,這兩種字體分別在編號為6和8的對象中定義。該頁面的內(nèi)容在編號為5的對象中描述,該對象中包含頁面繪圖的流信息,示例中的 “. . .”代表這部分流信息。如果使用二進(jìn)制文件編輯器打開PDF文件,會發(fā)現(xiàn)這部分流信息看起來是一長串不可讀的隨機(jī)數(shù),原因是那是壓縮數(shù)據(jù)。流數(shù)據(jù)采用Zlib方法壓縮,壓縮方式由字典對象“/Filter /FlateDecode”描述,被壓縮流的大小為2319字節(jié)。解壓這部分流信息,前面幾行內(nèi)容如下所示:
q
37.08 56.424 537.84 679.18 re
W* n
/P <</MCID 0>> BDC 0.753 g
36.6 465.43 537.96 24.84 re
f*
EMC ?/P <</MCID 1/Lang (x-none)>> BDC BT
/F1 18 Tf
1 0 0 1 39.6 718.8 Tm
0 g
0 G
[(GRA)29(NOTECH LI)-3(MIT)-4(ED)] TJ
ET
這是頁面描述語言的一個小例子。 示例中, “re” 代表矩形,“re” 前面的4個數(shù)字代表矩形的位置和大小,依次為:起點橫坐標(biāo)、起點縱坐標(biāo)、寬度、高度。
這個簡單的例子演示了PDF文件內(nèi)部實現(xiàn)的總體思路。從頁面層次結(jié)構(gòu)的根對象開始, 每一頁都定義了諸如字體、圖片、內(nèi)容流的資源,內(nèi)容流由操作符和繪制頁面所需要的參數(shù)構(gòu)成。PDF文件分析器會產(chǎn)生一個對象匯總文件,該文件包含非流對象的其他所有對象。每個數(shù)據(jù)流會被解碼并保存為一個單獨的文件, 頁面描述流保存為文本格式的文件, 圖片流保存為.jpg或.bmp格式的文件,字體流保存為.ttf格式的文件,其他二進(jìn)制流保存為.bin 格式的文件,文本流保存為.txt格式的文件。通過另一個解析過程,晦澀難懂的頁面描述會被轉(zhuǎn)換為偽C#代碼,如上例中的頁面描述被轉(zhuǎn)為:
SaveGraphicsState(); // q
Rectangle(37.08, 56.424, 537.84, 679.18); // re
ClippingPathEvenOddRule(); // W*
NoPaint(); // n
BeginMarkedContentPropList("/P", "<</MCID 0>>"); // BDC
GrayLevelForNonStroking(0.753); // g
Rectangle(36.6, 465.43, 537.96, 24.84); // re
FillEvenOddRule(); // f*
EndMarkedContent(); // EMC
BeginMarkedContentPropList("/P", "<</Lang(x-none)/MCID 1>>"); // BDC
BeginText(); // BT
SelectFontAndSize("/F1", 18); // Tf
TextMatrix(1, 0, 0, 1, 39.6, 718.8); // Tm
GrayLevelForNonStroking(0); // g
GrayLevelForStroking(0); // G
ShowTextWithGlyphPos("[(GRA)29(NOTECH LI)-3(MIT)-4(ED)]"); // TJ
EndTextObject(); // ET
文章接下來的部分將對PDF文件的結(jié)構(gòu)和解析過程進(jìn)行更為詳細(xì)的描述,接下來的章節(jié)包括:對象定義,文件結(jié)構(gòu),文件解析,文件讀取,以及使用PDF文件分析器編程。
3. 免責(zé)聲明
pdf 文件分析器能處理大量的文件,這是我在自己的系統(tǒng)上掃描眾多PDF文件的經(jīng)驗。不過,該程序不支持加密文件或者多個代文件(在對象不為零之前的第二個數(shù)字)。在PDF規(guī)格文件之中可用功能的數(shù)量是非常顯著的。這并不可能為一個單的個開發(fā)者系統(tǒng)地測試所有的功能。如果在整個文件分析期間該程序拋出一個異常,將顯示一條錯誤信息,該信息顯示源代碼模塊名和行號。
4.對象定義
PDF文件生成多個對象。在PDF文件分析器項目中每個PDF對象都有一個對應(yīng)的類。所有這些對象類都派生于PDFbase類。對象類定義源代碼是BasicObjects.cs.確卻地PDF對象定義在Adobe pdf文件 規(guī)格第三章之中是有用的
Boolean對象是靠PdfBoolean類來實現(xiàn)的. Boolean在PDF上的定義同C#上的是相同的.
Integer 對象是靠PdfInt類來實現(xiàn)的. PDF上的定義同C#上Int32的定義是相同的.
實數(shù)對象是靠PdfReal類來實現(xiàn)的. PDF上的定義同C#上的Single定義相同.
String 對象是靠PdfStr類來實現(xiàn)的. PDF上的定義同C#相比有所不同. String 是用字節(jié)構(gòu)造出來的,而不是字符. 它被包在圓括號()里面. PdfFileAnalyzer會把包含在圓括號中的C#字符串保存成PDF的字符串. PDF的字符串對于ASCII編碼非常有用.
十六進(jìn)制字符串獨享是靠PdfHex類來實現(xiàn)的. 它是由每字節(jié)兩個十六進(jìn)制數(shù)定義,并包在尖括號里面的字符串. PdfFileAnalyzer 將包含在尖括號中的C#字符串保存成PDF十六進(jìn)制字符串. 對于 PDF 讀取器,字符串和十六進(jìn)制字符串對象可用于同種目的. 字符串 (AB) 等同于<4142>. PDF 十六進(jìn)制字符串對于任意編碼的場景非常有用.
Name 對象是靠PdfName類來實現(xiàn)的. Name 對象是由打頭的正斜杠后面跟著一些字符組成的. 例如 /Width. Named 對象用作參數(shù)名稱. PdfFileAnalyzer 將正斜杠開頭的C#字符串保存成Name對象.
Null 對象是靠PdfNull類來實現(xiàn)的. PDF 對于null的定義基本上同C#中的是一樣的.
4.2. 復(fù)合的對象
Array 對象是靠 PdfArray 類來實現(xiàn)的. PDF 數(shù)組是一個封裝在一堆中括號中的對象的集合. 一個數(shù)組的對象可以是除了流之外的任何對象.PdfFileAnalyzer 將一個C#數(shù)組中的對象保存成PdfBase類
. 因為所有的對象都繼承自PdfBase,所有在這個數(shù)組中保存多種類型的對象沒有啥問題. 當(dāng)數(shù)組對象被轉(zhuǎn)換成一個字符串時(使用ToString()方法), 程序會在首位添加中括號. 數(shù)組可以是空的. 下面是一個有六個對象的數(shù)組示例: [120 9.56 true null (string) <414243>].
Dictionary 對象是靠PdfDict類實現(xiàn)的. PDF 字典是一組被包入一對雙尖括號中的鍵值對集合. Dictionary 的鍵是一個對象的名稱,而值則可以是除了流之外的任何對象. ?PdfFileAnalyzer 將一個鍵值對保存到PdfPair類中. 鍵是一個C#字符串,而值則是一個PdfBase.PdfDict 類有一個PdfPair類的數(shù)組. Dictionary 可以用鍵來訪問. 因而鍵值對的順序沒有啥意義. PdfFileAnalyzer 用鍵來對鍵值對進(jìn)行排序. 下面是一個有三個鍵值對的字典: <</CropBox [0 0 612 792] /Rotate 0 /Type /Page>>.
Stream 對象是靠PdfStream來實現(xiàn)的. Streams 被用來處理面熟語言,圖形和字體. PDF Stream 由一個字典和一個字節(jié)流組成. 字典中定義了流的參數(shù). 比如流對象中字典的一個鍵值對 /Filter. PDF 文檔定義了10種類型的過濾器. PdfFileAnalyzer 支持了4種. 這是我發(fā)現(xiàn)在實際場景中只會被用到那4種. 壓縮過濾器 FlateDecode 是現(xiàn)在的PDF寫入器最長被用到的過濾器. FlateDecode支持ZLib解壓縮. LZWDecode 壓縮過濾器在過去些年用的比較多. 為了能讀取比較老的PDF文件, 我們的程序支持這個過濾器. ASCII85Decode 過濾器將可被打印的ASCII轉(zhuǎn)換成二進(jìn)制位. DCTDecode 用于JPEG圖像的壓縮.PdfFileAnalyzer 為前三種實現(xiàn)了解壓縮. DCTDecode 流則以文件擴(kuò)展名.jpg保存. 它是一個可以被展示的圖片文件.
Object 流在PDF 1.5中被引入. 它是一個包含多個間接對象(在下面會描述道)的流. 上面描述的Stream 對象一次只壓縮一個流. Object 流會將所有包含進(jìn)來的流壓縮到一個壓縮域中.
多引用流在PDF 1.5中被引入. 它是一個包含多引用表格的流,下文會描述到.
內(nèi)聯(lián)圖片對象是靠 PdfInlineImage來實現(xiàn)的. 它是一個帶有一個流的流. 內(nèi)聯(lián)圖片是頁面描述語言的一部分. 它由BI-開頭圖形, ID-圖形數(shù)據(jù)和EI-結(jié)尾圖形這三個操作符組成. BI 和 ID 之間的區(qū)域是一個圖形字典,而ID 和 EI 之間的區(qū)域則包含圖形數(shù)據(jù).
4.3. 間接對象
間接對象是靠 PdfIndirectObject實現(xiàn)的. 它是一個PDF文檔的主要構(gòu)造塊. 間接對象是任何被包在 “n 0 obj” 和 “endobj”之間的對象. 其它對象可以通過設(shè)定“n 0 R”來引用間接對象. “n”代表對象編號. “0”代表生成編號. 這個程序不支持0之外的生成編號. PDF 規(guī)范允許其它的編號. 多代生成的理念允許PDF的修改操作是在保留原有文件的基礎(chǔ)上追加變更.
對象引用時一種引用間接對象的方法. 例如 /Pages 2 0 R 是目錄對象中的字典里的一項. 它是一個指向 /Pages 對象的指針. pages對象是編號為2的間接對象.
4.4. 操作符和關(guān)鍵詞
操作符和關(guān)鍵詞不被認(rèn)為是PDF對象. 而PdfFileAnalyzer 程序有一個PdfOp 和一個PdfKeyword 類可以從中得到 PdfBase 的類. 在轉(zhuǎn)換過程中,轉(zhuǎn)換器為每一個可用的字符序列創(chuàng)建了一個 PdfOp 或者PdfKeyword . Pdf文件規(guī)范的附錄A-操作符總結(jié)中列出了所有的操作符. 列表中有73個操作符. 下面是一些操作符的示例: BT-打頭的文本對象, G-用于做記號的設(shè)置灰度操作, m-移動到, re-矩形和Tc-設(shè)置字符間距. 下面是關(guān)鍵詞的示例: stream, obj, endobj, xref.
5. 文件結(jié)構(gòu)
PDF文件由四個部分構(gòu)成: 頭部Header , 主體body, 多引用cross-reference 和附帶簽名 trailer signature.
Header: 頭部是文件的簽名. 它必須是 %PDF-1.x , x 從 0 到 7.
Body: 主體區(qū)域包含所有的間接對象.
Cross-reference: 多引用是一個指向所有間接對象的文件位置指針列表. 有兩種類型的多引用表格. 原始的類型有ASCII字符組成. 新式的是一個包含一個間接對象的流. 信息以二進(jìn)制數(shù)字編碼. 在多引用表格的結(jié)束部分有一個附件字典. 一個文件可以有超過一個的多引用區(qū)域.
Trailer signature: 附帶簽名由關(guān)鍵詞“startxref”, 最后一個多引用表格的偏移位, 和結(jié)束簽名 %%EOF 組成. 請注意: 附帶簽名是多引用區(qū)域的一部分.
6. 文件轉(zhuǎn)換
PDF 文件是一個字節(jié)的序列. 一些字節(jié)有特殊的意義.
空格被定義成: null, tab, 換行, 換頁, 回車和間隔.
分隔符被定義成: (, ), <, >, [, ], {, }, /, %, 以及空格字符.
文件轉(zhuǎn)換是由PdfParser 類來完成的. 開始進(jìn)行轉(zhuǎn)換過程是,程序會設(shè)置文件需要被轉(zhuǎn)換區(qū)域的位置. ParseNextItem() 是提取下一個對象的方法.
解析器跳過空格符和注釋。如果下一個字節(jié)是“(”,判斷對象為一個字符串。如果下一個字節(jié)是“[”,判斷對象是一個數(shù)組。如果接下來的兩個字節(jié)是“<<”,判斷對象是一個字典。如果下一個字節(jié)是“<”,判斷對象是一個十六進(jìn)制字符串。如果下一個字節(jié)是“/”,判斷對象是一個名稱。如果下一個字節(jié)不是上述任何一種,解析器會采集隨后的字節(jié)直到發(fā)現(xiàn)定界符。定界符不是當(dāng)前標(biāo)記符的一部分。標(biāo)記符可以是整數(shù),實數(shù),操作符或關(guān)鍵詞。在整數(shù)的情況下,程序?qū)⑦M(jìn)一步搜索對象引用“n 0 R”或間接對象“n 0 obj”中 n 為該整數(shù)的對象。從 ParseNextItem() 返回的值是第4節(jié)“對象的定義”中所述的適當(dāng)對象。對象的類作為 PdfBase 類返回。
在數(shù)組或字典的情況下,程序?qū)?zhí)行遞歸調(diào)用 ParseNextItem() 來解析數(shù)組或字典的內(nèi)部對象。
7. 文件讀取
PdfDocument 類是 PDF 文件分析的主要類。入口方法是 ReadPdfFile(String FileName)。程序以二進(jìn)制讀取的方式打開 PDF 文件(一次一個字節(jié))。
文件分析開始于檢查頭部簽名 %PDF-1.x(x為0到7)和結(jié)尾簽名%%EOF。有人會認(rèn)為,所有的 PDF 生成器會把頭部簽名放在文件的零位置,結(jié)尾簽名放在文件的最后。不幸的是,實際并非如此。程序必須在文件的兩端搜索這兩個簽名。如果頭部簽名不在零位置,所有間接對象的文件位置的指針也必須調(diào)整。
就在結(jié)尾簽名的前面有一個指向最后一個交叉引用表開始位置的指針。
========
Windows下的開源二進(jìn)制文件編輯器HexEdit
http://blog.okbase.net/haobao/archive/65.html?
作者:Andrew Phillips
?
[譯者按]HexEdit是一個偉大的軟件,多少年來一直未伴隨著我們,如今作者釋放出全部源代碼,真的讓我們感激萬分。本文摘錄翻譯了部分,原文請參見http://www.codeproject.com/Articles/135474/HexEdit-Window-Binary-File-Editor
??
介紹
我在去年公測后發(fā)布了hexedit 4.0正式版。測試版工作得很好,所以我并沒有急于釋放正式版,有些小BUG需要修復(fù)。
?
HexEdit用C++編寫,需要VS2008(帶功能包)、VS2012或后續(xù)版本和MFC的支持。你很容易編譯生成它,如果有問題請參閱“生成HexEdit 4.0”章節(jié),現(xiàn)在也有一個工程文件是針對VS2012的。
?
HexEdit(1999年)的第一個版本是開源的,但后來的版本是共享軟件(雖然我一直堅持在做一個免費的版本)。hexedit的2.0開放源代碼,因為它使用了一些BCG商業(yè)庫。(BCG庫是一個很好的MFC擴(kuò)展庫,所以我不后悔使用它。)幸運的是,幾年前,微軟買了BCG代碼,并把它納入MFC。所以,現(xiàn)在hexedit的4.0是第一次開源(見 http://www.hexedit.com);也有一個共享軟件版本,可用于那些想為它支付的朋友(見 http://www.hexeditpro.com),增加了一些小功能。
?
要生成hexedit 4.0中,您只需要Visual Studio,加上一些開放的源代碼和庫(其中大部分來自CodeProject)。您可以使用程序或任何的源代碼,不管出于什么目的,你認(rèn)為合適的,只要你遵守的相關(guān)許可要求(見下文)或任何包含第三方代碼的具體要求。
?
開發(fā)歷史
?
我在1997-1998寫的HexEdit,當(dāng)時工作中需要用到,而那時正缺少十六進(jìn)制編輯器。
hexedit被設(shè)計為易于使用和用戶熟悉的Windows軟件,就像MS Word和Visual Studio。事實上,它借鑒了一些常見的Windows程序的很多思路。
?
代碼文件
HexEdit.h - CHexEditApp 類是應(yīng)用程序類。
Stdafx.h - 預(yù)編譯頭文件
resource.h - 資源 IDs,用于 HexEdit.rc 和C++代碼
?
MainFrm.h - 主程序窗口MFC類
ChildFrm.h - 處理每個文件的窗口類
HexEditDoc.h - CHexEditDoc 類 (參閱 HexEditDoc.cpp, DocData.cpp, Template.cpp, BGSearch.cpp, BGAerial.cpp).
HexEditView.h - CHexEditView 類(參閱 HexEditView.cpp 和 Printer.cpp)
ScrView.h - CScrView 提供了可滾屏的視圖 (CHexEditView的基類)
DataFormatView.h - CDataFormatView 處理模板顯示 (參閱 Template.cpp)
AerialView.h - CAerialView class - 顯示 aerial 視圖 (參閱 BGAerial.cpp)
?
Prop.h - 屬性對話框類 (property sheet, property pages and controls)
BookMarkDlg.h - CBookMarkDlg 對話框用于顯示、添加書簽(參見bookmark.h)?
FindDlg.h - 查找對話框?qū)?yīng)類 (property sheet and pages)?
Explorer.h - HexEdit 瀏覽對話框 (dialog and control classes)?
CalcDlg.h - CCalcDlg 計算器對話框類 (see also CalcEdit.h below)
?
Options.h - 選項對話框的屬性頁
DFFD*.h - 模板編輯對話框?
TParseDlg.h - 模板編輯時使用的C/C++分析對話框 (參見TParse.h)
NewFile.h - “新文件”和“插入塊”對話框
OpenSpecialDlg.h - 磁盤編輯打開特殊對話框 (參見SpecialList.h)?
RecentFileDlg.h - 顯示最近使用的文件對話框 (參見HexFileList.h)?
CopyCSrc.h - CCopyCSrc對話框,用于 "Copy As C Source"?
Algorithm.h - CAlgorithm 類用于加密算法對話框
Password.h - CPassword 類用于密碼加密對話框
CompressDlg.h - zlib壓縮對話框
EmailDlg.h - 郵件對話框
Tipdlg.h - 顯示每日技巧
Dialog.h - 在宏中使用的對話框 (GetStr CMacroMessage CSaveMessage CMultiplay
- 還有CFileDialog 派生類,包括 CHexFileDialog)
HexPrintDialog.h - 自定義打印對話框 (重載 MFC CPrintDialog?
SaveDffd.h - 模板沒有保存時的提示對話框 (save/save as/cancel)?
NewScheme.h - small dialog used when creating a new color scheme?
BookmarkFind.h - used by Find dialog when bookmarking found occurrences?
DirDialog.h - directory selection dialog (see below)
?
Splasher.h - CSplashWnd for splash screen (see below)?
TipWnd.h - CWnd derived class to show a small "tip" window (see below)?
TransparentListBox.h, TransparentStatic2.h - transparent controls (see below)?
CCalcEdit.h - CCalcEdit class which handles calculator edit box?
control.h - various text and combo controls used in dialogs and on toolbars
?
GenDockablePane.h - dockable window used to makes Calculator, Find dialog etc dockable?
ResizeCtrl.h - CResizeCtrl (see below)?
BCGMisc.h - a few classes derived from BCG (now MFC) classes?
UserTool.h - CHexEditUserTool is derived from CUserToolto allow command line substition for user tools?
SimpleSplitter.h - CSimpleSplitter is used in Explorer dialog for the split between folder/file sections?
HexEditSplitter.h - CHexEditSplitter allows showing aerial/template views in a split window?
TabView.h - CHexTabView (derived from CTabView allows showing aerial/template views in tabs?
CoordAp.h - CPointAp CSizeAp CRectAp (see below) for 64-bit (vertically) coordinate system
?
TParser.h - 用于TParseDlg的C/C++代碼分析器 (參閱下面的TParseDlg.h)?
HexEditMacro.h - handles recording and playback of Keystroke macros?
HexFileList.h - stores global list of all recent files?
SpecialList.h - stores info about that volumes and raw disks in the system?
Bookmark.h - CBookmarkList class for global storage for bookmarks?
Scheme.h - CScheme stores all color schemes?
NavManager.h - global storage of navigation points?
SystemSound.h - CSystemSound contains static method for getting, setting, playing sounds (see below)?
Timer.h - timer class can time events (see below)
?
UpdateChecker.h - 通過Internet檢測HexEdit的最新版本
Xmltree.h - 封裝了MS XML SDK
BigInter.h - BigInteger 類用于處理大于64位的數(shù)字
CFile64.h - CFile64 類用于64位文件處理?
crypto.h - CCrypto 類封裝了 Crypto API
Boyer.h - boyer類用于搜索
range_set.h - template class for set with ranges (see below)?
Expr.h - expr_eval class handles C-like expressions (used in templates etc)?
IntelHex.h - CReadIntelHexand CWriteIntelHex (see below)?
SRecord.h - CReadSRecordand CWriteSRecord (see below)
?
misc.h - 雜項全局函數(shù)
md5.h - routines for generating an MD5 checksum
ntapi.h - declarations for direct access to NT API (bypassing Windows) for disk editor?
w2k_def.h - more NT (not 9X) info - included by ntapi.h?
optypes.h - defines unary and binary operations (for Calculator and Operations menu)
SVNRevisionTemplate.h - used by SVN uitlity to create SVNRevision.hSVNRevision.h - just stores?
?
相關(guān)內(nèi)容
下載源代碼:http://www.okbase.net/file/item/19711
更多內(nèi)容請參見http://www.codeproject.com/Articles/135474/HexEdit-Window-Binary-File-Editor
========
總結(jié)
以上是生活随笔為你收集整理的C#二进制文件编程实践的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# Image 学习总结
- 下一篇: C# 操作Sql Server 学习总结