Unit 'sysutils' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

GetFileAsString

Return the contents of a file as a string.

Declaration

Source position: filutilh.inc line 293

function GetFileAsString(

  const aFileName: RawByteString

):RawByteString;

function GetFileAsString(

  const aFileName: RawByteString;

  aEncoding: TEncoding

):RawByteString;

function GetFileAsString(

  const aFileName: UnicodeString

):UnicodeString;

function GetFileAsString(

  const aFileName: UnicodeString;

  aEncoding: TEncoding

):UnicodeString;

Description

GetFileAsString returns the contents of aFileName or aHandle as a string. You can specify the string encoding in the aEncoding argument. If no encoding is specified TEncoding.SystemEncoding is used. The whole file is read in the case of aHandle: The file position is first set to offset zero.

Errors

If an invalid file handle or a file handle that does not support the seek operation, a EInOutError exception is raised.

See also

GetFileContents

  

Return the contents of a file as an array of bytes.

TEncoding.SystemEncoding

  

System encoding.

TEncoding.GetAnsiString


Documentation generated on: Nov 22 2024