public void CompareFiles()
{
//listBox1.BeginUpdate();
//listBox2.BeginUpdate();
//listBox1.Items.Clear();
//listBox2.Items.Clear();
currstrList.Clear();
compstrList.Clear();
try
{
if (File.Exists(_currentfilename))
{
if (File.Exists(_comparefilename))
{
FileInfo fi = new FileInfo(_currentfilename);
FileInfo fi2 = new FileInfo(_comparefilename);
linediffs = new bool[fi.Length / 16];
if (true)// (fi.Length == fi2.Length)
{
byte[] currfile = File.ReadAllBytes(_currentfilename);
byte[] compfile = File.ReadAllBytes(_comparefilename);
// mark the differences in the hexboxes
//FileStream fsi1 = File.OpenRead(_currentfilename);
//BinaryReader br1 = new BinaryReader(fsi1);
//FileStream fsi2 = File.OpenRead(_comparefilename);
//BinaryReader br2 = new BinaryReader(fsi2);
for (int tel = 0; tel < (fi.Length / 16); tel++)
{
try
{
//Byte[] ib1 = br1.ReadBytes(16);
//Byte[] ib2 = br2.ReadBytes(16);
if (!ByteCompare(currfile, compfile, (tel * 16)))
{
linediffs[tel] = true;
Int32 addr = tel * 16;
string s1 = addr.ToString("X6") + ": ";
string s2 = s1;
for (int t = 0; t < 16; t++)
{
Byte b1 = (Byte)currfile.GetValue((tel*16) + t);
Byte b2 = (Byte)compfile.GetValue((tel * 16) + t);
s1 += b1.ToString("X2") + " ";
s2 += b2.ToString("X2") + " ";
}
// add to string array
//listBox1.Items.Add(s1);
currstrList.Add(s1);
compstrList.Add(s2);
//listBox2.Items.Add(s2);
}
else
{
linediffs[tel] = false;
if (!checkButton1.Checked)
{
Int32 addr = tel * 16;
string s1 = addr.ToString("X6") + ": ";
string s2 = s1;
for (int t = 0; t < 16; t++)
{
Byte b1 = (Byte)currfile.GetValue((tel * 16) + t);
Byte b2 = (Byte)compfile.GetValue((tel * 16) + t);
s1 += b1.ToString("X2") + " ";
s2 += b2.ToString("X2") + " ";
}
// listBox1.Items.Add(s1);
// listBox2.Items.Add(s2);
currstrList.Add(s1);
compstrList.Add(s2);
}
}
}
catch (Exception cE)
{
Console.WriteLine(cE.Message);
}
}
//fsi1.Close();
//br1.Close();
//fsi2.Close();
//br2.Close();
}
}
}
}
catch (Exception E)
{
MessageBox.Show(E.Message);
}
//listBox1.EndUpdate();
//listBox2.EndUpdate();
listBox1.Count = currstrList.Count;
listBox2.Count = compstrList.Count;
}