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

# TTarArchive.ReadFile

Read a file from the archive

## Declaration

Source position: libtar.pp line 171

`public procedure TTarArchive.ReadFile(`
`Buffer: POINTER`
`); overload; procedure TTarArchive.ReadFile(`
`Stream: TStream`
`); overload; procedure TTarArchive.ReadFile(`
`Filename: string`
`); overload; function TTarArchive.ReadFile: string; overload;`

## Arguments

`Buffer` |  | Memory buffer to copy file contents to.

## Arguments

`Stream` |  | Stream to copy file contents to.

## Arguments

`Filename` |  | Filename for file in which to write file content.

## Function result

File contents as string

## Description

ReadFile can be used to read the current file in the archive. It can be called after the archive was successfully positioned on an entry in the archive. The file can be read in various ways:

- directly in a memory buffer. No checks are performed to see whether the buffer points to enough memory.
- It can be copied to a Stream.
- It can be copied to a file with name FileName.
- The file content can be copied to a string

## Errors

An exception may occur if the buffer is not large enough, or when the file specified in filename cannot be opened.

Documentation generated on: May 14 2021