I've just started C# and have little experience with programming. I've browsed trhough many topics in this forum but none seem to be exactly what I'm looking for...
I want to create a tool which compares to files, not in bytesize but in by content. I've managed to create a tool who does so, but he compares complete files. I'm unable to create a way the tool stops when a certain phrase comes up. So I had the idea to create two temporary files which I compare, but here I have the same problem. I'm unable to copy a certain block of data.
Is there anybody who can help me with my problem?
Loading
DennisPosted Jan 15, 2008, 3:12 AM
private bool AreFilesEqual(string filePathOne, string filePathTwo)
{
StreamReader fileOneReader = new StreamReader(new FileStream(filePathOne, FileMode.Open));
StreamReader fileTwoReader = new StreamReader(new FileStream(filePathTwo, FileMode.Open));
if(fileOneReader.ReadToEnd() != fileTwoReader.ReadToEnd())
return false;
else
return true;
}
Because of the ReadToEnd() it compares the complete file. This is not what I want.
Posted Jan 14, 2008, 4:13 PM
private bool AreFilesEqual(string filePathOne, string filePathTwo)
{
StreamReader fileOneReader = new StreamReader(new FileStream(filePathOne, FileMode.Open));
StreamReader fileTwoReader = new StreamReader(new FileStream(filePathTwo, FileMode.Open));
if(fileOneReader.ReadToEnd() != fileTwoReader.ReadToEnd())
return false;
else
return true;
}
Im not quite sure though what you are trying to copy. Do you want to copy the line of data that is in one file and not the other to the file that is missing it?