Skip to content

File_InsertInFile

Inserts string in file

File_InsertInFile(sFile, sSearchString, sInsertString, bOnlyFirstOccurence, bIgnoreCase, sMode) As Boolean

Filename

Pre-string to find. A line matches when it contains this string anywhere in the line. Not used with the modes TOP and BOTTOM.

String to insert before or after pre-string. It’s inserted as a separate line.

Insert by first occurrence (TRUE or FALSE)

Ignore case (TRUE or FALSE)

Insert-mode. sMode can be one of following values (not case-sensitive):

Value Result
TOP Inserts the string as the first line of the file.
BOTTOM Inserts the string as the last line of the file.
BEFORE Inserts the string on a new line before each matching line.
AFTER Inserts the string on a new line after each matching line.
  • The file must exist and must not be read-only. Otherwise the function returns False.
  • The file is read and written as ANSI text. See Text file encoding.
If bStatus Then bStatus = File_InsertInFile(gsWindowsDir & "\WIN.BAK", "", gsWindowsDir & "\WIN.BAK was created " & Now, True, True, "TOP")

Scripting Guidelines

File_AppendToFile File_FindInFile File_GetLineString Constants Package Property Variables