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

# TTarWriter.AddFile

Add a file to the archive

## Declaration

Source position: libtar.pp line 199

`public procedure TTarWriter.AddFile(`
`Filename: string;`
`TarFilename: AnsiString = ''`
`);`

## Arguments

`Filename` |  | File to add to the archive
`TarFilename` |  | Alternative filename, stored in archive

## Description

AddFile adds a file to the archive: the contents is read from FileName. Optionally, an alternative filename can be specified in TarFileName. This name should contain only forward slash path separators. If it is not specified, the name will be computed from FileName.

The archive entry is written with the current owner data and permissions.

## Errors

If FileName cannot be opened, an exception will be raised.

## See also

TTarWriter.AddStream |  | Add stream contents to archive.
TTarWriter.AddString |  | Add string as file data
TTarWriter.AddLink |  | Add hard link to archive
TTarWriter.AddSymbolicLink |  | Add a symbolic link to the archive
TTarWriter.AddDir |  | Add directory to archive
TTarWriter.AddVolumeHeader |  | Add volume header entry