Hey guys, currently this code checks for differences between 2 text files. One of these files is bigger then the other. Problem is that this code only checks until the end of one of the files. Also, if any lines were deleted from the 2nd file, the whole code logic would go haywire.
Can anyone guide me as to how to modify the code so that it'll be able to check until the end of both files, which lines are missing from file 1 and file 2.
Like lets say file 1 has test=test but file 2 doesnt have it.
It'll show like file 2 doesnt have test = test
If file 2 has t = t but file 1 doesnt.
It'll show like file 1 doesnt have t = t
This is the code. Really hope someone can help
Regards
Can anyone guide me as to how to modify the code so that it'll be able to check until the end of both files, which lines are missing from file 1 and file 2.
Like lets say file 1 has test=test but file 2 doesnt have it.
It'll show like file 2 doesnt have test = test
If file 2 has t = t but file 1 doesnt.
It'll show like file 1 doesnt have t = t
This is the code. Really hope someone can help
Regards
Dim fsRegPre As New FileStream("snapRegPre.tmp", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
Dim fsRegNew As New FileStream("snapRegNew.tmp", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
'declaring a FileStream to open the file named file.doc with access mode of reading
Dim srRegPre As New StreamReader(fsRegPre)
Dim srRegNew As New StreamReader(fsRegNew)
'creating a new StreamReader and passing the filestream object fs as argument
srRegPre.BaseStream.Seek(0, SeekOrigin.Begin)
srRegNew.BaseStream.Seek(0, SeekOrigin.Begin)
'Seek method is used to move the cursor to different positions in a file, in this code, to the beginning
'peek method of StreamReader object tells how much more data is left in the file
Dim regTempNew As String = srRegNew.ReadLine
Dim regTempPre As String = srRegPre.ReadLine
Dim x As ListViewItem
While srRegNew.Peek > -1 Or srRegPre.Peek > -1
If Not regTempNew Is Nothing Then
If regTempNew.ToLower.StartsWith("[hkey") Then
Label1.Text = regTempNew
End If
If regTempNew.CompareTo(regTempPre) = 0 Then
regTempPre = srRegPre.ReadLine()
Else
If Not regTempNew.ToLower.StartsWith("[hkey") Then
x = frmC.ListView2.Items.Add("")
x.SubItems.AddRange(New String() {Label1.Text & "\\" & regTempNew})
'ListBox1.Items.Add(Label1.Text & "\\" & regTempNew)
Else
x = frmC.ListView2.Items.Add("")
x.SubItems.AddRange(New String() {regTempNew})
'ListBox1.Items.Add(regTempNew)
End If
End If
regTempNew = srRegNew.ReadLine()
End If
End While