Überprüfen, ob ein TEXT in einer DATEI enthalten ist:
If StringInStr(FileRead('C:\Test.txt'), 'String') Then MsgBox(0,"", "String vorhanden!")
Ausführlich:
$Dateipfad = 'C:\Test.txt'
$Suchstring = 'String'
$Dateitext = FileRead($Dateipfad)
If StringInStr($Dateitext, $Suchstring) Then MsgBox(0,"", "String vorhanden!")
oder:
If StringInStr(FileRead($Dateipfad), $Suchstring) Then MsgBox(0,"", "String vorhanden!")
Text in einer Datei finden und ersetzen:
$ConfigFile = $Path & "\" & "File.config"
$Find = "SUCHEN"
$replace = "Finden"
$retval = 0
Local $retval = _ReplaceStringInFile($ConfigFile, $Find, $replace)
If $retval < 1 Then
; MsgBox(0, "ERROR", "The pattern " & $Find & " could not be replaced in file: " & $ConfigFile & " Error: " & @error)
Else
MsgBox(0, "INFO", "Found " & $retval & " occurances of the pattern: " & $find1 & " in the file: " & $ConfigFile)
MsgBox(0, "INFO", "Replaced ServerName " & $Find & " in Config File to " & $replace)
EndIf
Text-Teile in einer Datei finden und Zeile ersetzen, oder anhängen, wenn nicht gefunden: