[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'FileUtil' (#lcl)

# ReadFileToString

ReadFileToString - returns a string with the contents of the named file

## Declaration

Source position: fileutil.pas line 175

`function ReadFileToString(`
`const Filename: String`
`):String;`

## Arguments

`Filename` |  | The name of the file for processing

## Function result

The contents of the file as a string, or an empty string if there is an error or the file is empty

## Description

ReadFileToString - returns a string with the contents of the named file

Opens the file and reads its contents into a Stream, then reads the stream to construct the Result string

## Errors

If there is an error in reading the file, an exception is raised and an empty string is returned

The latest version of this document can be found at lazarus-ccr.sourceforge.net.