I have to test that when searching for a file by name in a directory it does not exist and I indicate it on the screen. I show you my code, where is the comment of the interrogations is where I have the problem, the rest works correctly:
static void recorrerDirectoriosYCompararPorFicheros(string dir1, string dir2)
{
System.IO.DirectoryInfo dirOrigenInfo = new DirectoryInfo(dir1);
System.IO.DirectoryInfo dirDestinoInfo = new DirectoryInfo(dir2);
System.IO.FileInfo[] fileDirOrigenNames = dirOrigenInfo.GetFiles("*.*");
System.IO.FileInfo[] fileDirDestinoNames = dirDestinoInfo.GetFiles("*.*");
for (int i = 0; i <= (fileDirOrigenNames.Length) - 1; i++)
{
System.IO.FileInfo file = fileDirOrigenNames[i];
for (int j = 0; j <= (fileDirDestinoNames.Length) - 1; j++)
{
System.IO.FileInfo file2 = fileDirDestinoNames[j];
if (file.Name.Equals(file2.Name))
{
mostrarResultadoComparacionPropiedades(file.FullName, file2.FullName);
}
else//????????????????????
{
Console.WriteLine("\nEl archivo {0} no existe en {1}", file.Name, dir2);
}
}
}
}
Here I leave the result, it tells me comparison by comparison if it exists or not, what I want is to go through the directory and tell me only once if it exists or not, the file that does not exist is c.txt
:
Creation date or last modification are NOT the same
The C: \ Projects \ OriginalFile \ a.txt and C: \ Projects \ Carpe files
taDestino \ a.txt are not equal by creation date and last modification
The a.txt file does not exist in C: \ Projects \ TargetFile
The a.txt file does not exist in C: \ Projects \ TargetFile
The a.txt file does not exist in C: \ Projects \ TargetFile
The c.txt file does not exist in C: \ Projects \ TargetFile
The c.txt file does not exist in C: \ Projects \ TargetFile
Creation date and last modification are the same C: \ Projects \ Source_folder \ c.txt and C: \ Projects \ FolderDestin or \ c.txt They are the same by date of creation and last modification
The c.txt file does not exist in C: \ Projects \ TargetFile
The Configuration.ini file does not exist in C: \ Projects \ TargetFile
The Configuration.ini file does not exist in C: \ Projects \ TargetFile
The Configuration.ini file does not exist in C: \ Projects \ TargetFile
Creation date or last modification are NOT the same Files C: \ Projects \ FolderOrigin \ Configuration.ini and C: \ Pr ojects \ Destinationfolder \ Configuration.ini are not equal by date of creation and last modification