Skip to content

File_ReplaceInFile

Searches file for specified text-string and replace it with a new string

File_ReplaceInFile(sFile, sSearchString, sReplacementString, bOnlyFirstOccurence, bIgnoreCase) As Boolean

Source-file

String to replace

New string

Only first matching string will be replaced. If False, the first match in each line is replaced.

Ignore case

  • The function replaces at most one match per line. If a line contains the search string more than once, only the first match in that line is replaced. To replace the other matches, call the function again.
  • The file must exist and must not be read-only. Otherwise the function returns False.
  • The number of replacements is written to the job log.
  • The file is read and written as ANSI text. See Text file encoding.
If bStatus Then bStatus = File_ReplaceInFile("C:\CapaInstaller.txt", "1999", "2000", False, True)

Scripting Guidelines

File_AppendToFile File_FindInFile File_GetLineString File_InsertInFile Constants Package Property Variables