1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
Const STR_SPECIAL_LINE = "B95A"
Const STR_NEW_LINE = "la nouvelle ligne à insérer"
nomfich="test.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set fich_source = fs.OpenTextFile(nomfich, 1, False)
Set nouv_fich = fs.OpenTextFile(left(nomfich,len(nomfich)-4) & "_new.txt", 2, true)
Do While not fich_source.AtEndOfStream
strTmpLine = fich_source.readLine
nouv_fich.writeLine strTmpLine
If StrComp(strTmpLine, STR_SPECIAL_LINE, vbText) = 0 Then nouv_fich.writeLine STR_NEW_LINE
Loop
nouv_fich.close
fich_source.close
Set nouv_fich=nothing
Set fich_source=nothing
Set fs=nothing |
Partager