# File_InsertInFile

> Inserts a string into a file — at the top or bottom, or before or after a search string.

Source: https://docs.capaone.com/capainstaller/vb-scripting-library/file-functions/file-insertinfile/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

#### Description

Inserts string in file

### Syntax

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

### Parameters

#### sFile (String)

Filename

#### sSearchString (String)

Pre-string to find

#### sInsertString (String)

String to insert before or after pre-string

#### bOnlyFirstOccurence (Boolean)

Insert by first occurrence (TRUE or FALSE)

#### bIgnoreCase (Boolean)

Ignore case (TRUE or FALSE)

#### sMode (String)

Insert-mode. sMode can be one of following values: 'TOP', 'BOTTOM', 'BEFORE', 'AFTER'

### Example

**VBScript**

```vb
If bStatus Then bStatus = File_InsertInFile(gsWindowsDir & "\WIN.BAK", "", gsWindowsDir & "\WIN.BAK was created " & Now, True, True, "TOP")
```

[Scripting Guidelines](/capainstaller/vb-scripting-library/scripting-guidelines/)

#### Related functions

[File_AppendToFile](/capainstaller/vb-scripting-library/file-functions/file-appendtofile/) [File_FindInFile](/capainstaller/vb-scripting-library/file-functions/file-findinfile/) [File_GetLineString](/capainstaller/vb-scripting-library/file-functions/file-getlinestring/) [Constants](/capainstaller/vb-scripting-library/addendum/constants/) [Package Property](/capainstaller/vb-scripting-library/addendum/package-property/) [Variables](/capainstaller/vb-scripting-library/addendum/variables/)
