Dim numFile1 As Long Dim numFile2 As Long Dim difference_detected As Boolean Dim s1 As String Dim s2 As String difference_detected = False numFile1 = FreeFile Open "C:\mon_premier_fichier_texte.txt" For Input As #numFile1 Line Input #numFile1, s1 ' Skip de la première ligne numFile2 = FreeFile Open "C:\mon_second_fichier_texte.txt" For Input As #numFile2 Line Input #numFile2, s2 ' Skip de la seconde ligne While (Not (EOF(numFile1)) And (Not EOF(numFile2))) And difference_detected = False Line Input #numFile1, s1 Line Input #numFile2, s2 If Trim(s1) <> Trim(s2) Then difference_detected = True End If Wend ' Verifie que les deux fichiers avaient la même taille If Not (EOF(numFile1) And EOF(numFile2)) Then ' L'un des deux fichiers n'est pas complètement lu difference_detected = True End If Close #numFile2 Close #numFile1 If difference_detected Then Kill "C:\mon_second_fichier_texte.txt" End If
Dim numFile1 As Long Dim numFile2 As Long Dim difference_detected As Boolean Dim s1 As String Dim s2 As String difference_detected = False numFile1 = FreeFile Open "C:\mon_premier_fichier_texte.txt" For Input As #numFile1 Line Input #numFile1, s1 ' Skip de la première ligne numFile2 = FreeFile Open "C:\mon_second_fichier_texte.txt" For Input As #numFile2 <s>Line Input #numFile2, s2 ' Skip de la seconde ligne</s> Line Input #numFile2, s2 ' Skip de la première ligne [...]
If difference_detected Then Kill "C:\mon_second_fichier_texte.txt" End If
If Not difference_detected Then Kill "C:\mon_second_fichier_texte.txt" End If
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question