WinForms에서 두 파일의 내용을 비교하고 싶습니다. 모든 파일은 각 행에 이름과 번호가있는 행을 포함합니다. 첫 번째 파일을 읽고 두 번째 파일과 비교하고 싶습니다. 라인이 같지 않으면 나는 그것을 추출하여 ArrayList에 추가하려고합니다. 지금까지 내가 한 일들을보세요 :C에서 두 파일의 내용 비교 #
Int32 nr = 0;
String linieinit=" ", liniewrt=" ";
ArrayList newlines = new ArrayList();
using (StreamReader fileinit = new StreamReader(Application.StartupPath + "/bontemp" + label_pin.Tag.ToString() + "initial"))
{
using (StreamReader filewrt = new StreamReader(Application.StartupPath + "/bontemp" + label_pin.Tag.ToString()))
{
while ((linieinit = fileinit.ReadLine()) != null && (liniewrt = filewrt.ReadLine()) != null)
{
Console.WriteLine(linieinit + " " + liniewrt);
if (linieinit.Equals(liniewrt))
{
nr = 0;
}
else
{
nr++;
newlines.Add(liniewrt);
}
}
filewrt.Close();
File.Delete(Application.StartupPath + "/bontemp" + label_pin.Tag.ToString());
}
fileinit.Close();
File.Delete(Application.StartupPath + "/bontemp" + label_pin.Tag.ToString() + "initial");
}
Console.WriteLine(nr);
if (nr == 0)
{
int pozition = 0;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["DenumireProdus"].Value.ToString(), print6B, Brushes.Black, x, 130 + height);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["produs_cantitate"].Value.ToString(), print6B, Brushes.Black, x + 110, 130 + height);
height += 15;
}
if (pozition > height)
{
pozition = height;
}
}
else
{
for (Int32 j = 0; j < newlines.Count; j++)
{
e.Graphics.DrawString(newlines[j].ToString(), print6B, Brushes.Black, x, 130 + height);
height += 15;
}
}
어떤 제안을 할 수 있습니까?
관련없는 코드 스타일 주석과 같이 중첩 된() 문을 사용하면 내 머리카락을 찢어지게 만들 수 있습니다. –
그리고 질문은 무엇입니까? – Magnus
그래서 무엇이 필요합니까? 당신의 질문은 무엇입니까 (http://stackoverflow.com/faq#questions)? –