Hi,
I am trying to create an application that gets the contents of two folders. It should compare the file names in the two folders and put files with different names into a list (unique). Each file with the same name in both folders should be read and the contents compared. If the actual contents of the two text files are the same, the filename should be added to list fileSame, otherwise it should be placed into the fileDifferent list.
I can compare the filenames but I cannot figure out how to compare the actual contents of the two files. I have pasted the code from my button below, Please Help :)
if(path1->Text != "" || path2->Text != "")
{
DirectoryInfo ^ dirInfo = gcnew DirectoryInfo(path1->Text);
DirectoryInfo ^ dirInfo2 = gcnew DirectoryInfo(path2->Text);
array< FileInfo ^ > ^ files = dirInfo->GetFiles();
array< FileInfo ^ > ^ files2 = dirInfo2->GetFiles();
for( int i = 0; i < files->Length; i++)
{
String ^ currFileName = files[i]->ToString();
bool result = false;
for( int j = 0; j < files2->Length; j++)
{
String ^ currFileName2 = files2[j]->ToString();
if(currFileName == currFileName2)
{
if(currFileName->Equals(currFileName2))
{
fileSame->Items->Add(files[i]);
result = true;
}
else
{
fileDifferent->Items->Add(files[i]);
result = true;
}
}
}
if(result == false)
{
fileUnique->Items->Add(files[i]);
}
}
Thanks,
Rob