# File_FindInFile

> Search for specified string in a file.

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

### Description

Search for specified string in a file.

### Syntax

File_FindInFile(sFile, sSearchString, bIgnoreCase, bMustExist) As Boolean

### Parameters

#### sFile (String)

Filename

#### sSearchString (String)

String to find

#### bIgnoreCase (Boolean)

Ignore case

#### bMustExist (Boolean)

String must exist

#### Return value

If sSeachString is found, gbValue is true, line numbers are returned in gaValue and gsValue will contain the content of the last line  
The function will return false if sSearchString is not found and bMustExist is true

### Example

**VBScript**

```vb
If bStatus Then bStatus = File_FindInFile("C:\CapaInstaller.txt", "CapaInstaller", True, True)
If bStatus And gbValue Then
  For index = LBound(gaValue) to UBound(gaValue)
    bStatus = Job_WriteLog("Custom", "String found in line: " & gaValue(index), bStatus, True)
  Next
End If
```

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

### Related functions

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