Comparaison et extraction de ligne de fichier.txt
Bonjour à tous,
je suis débutant :calim2: en VBS et je souhaiterais extraire les lignes différentes de deux fichiers.txt . Exp:
Fic1=
L1
L2
L3
Fic2=
L1
L2
L4
L5
je voudrais récupérer dans un fichier.txt(FicResult.txt) la difference = 4
voici ce que j'ai récupéré mais cela ne fonctionne pas
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f , f1, f2
Dim st ,st1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Fic1.txt", ForReading)
Set f1 = fso.OpenTextFile("C:\Fic2.txt", ForReading)
Set f2 = fso.CreateTextFile("C:\FicResult.txt")
Do Until f.AtEndOfStream
ligne = f.ReadLine
If Not objDictionary.Exists(ligne) Then
objDictionary.Add ligne, ligne
End If
Loop
f.Close
f1.Close
f2.Close
Set f2 = fso.OpenTextFile("C:\FicResult.txt", ForWriting)
For Each strKey in objDictionary.Keys
f2.WriteLine strKey
Next
f2.Close |
Merci pour votre aide.
Cordialement
Gardel