System.IOUtils.TFile.Replace

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

class procedure Replace(const SourceFileName, DestinationFileName,  DestinationBackupFileName: string); overload; {$IFDEF MSWINDOWS}inline; {$ENDIF} static;
class procedure Replace(SourceFileName, DestinationFileName,  DestinationBackupFileName: string; const IgnoreMetadataErrors: Boolean); overload; static;

C++

static void __fastcall Replace(const System::UnicodeString SourceFileName, const System::UnicodeString DestinationFileName, const System::UnicodeString DestinationBackupFileName)/* overload */;
static void __fastcall Replace(System::UnicodeString SourceFileName, System::UnicodeString DestinationFileName, System::UnicodeString DestinationBackupFileName, const bool IgnoreMetadataErrors)/* overload */;

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.IOUtils.pas
System.IOUtils.hpp
System.IOUtils TFile

Description

Replaces the contents of a file with the contents of another file.

Use Replace to replace the contents of a file with the contents of another file. Replace also makes a backup of the replaced file. The first form of Replace does not fail if the file metadata cannot be merged. The second form of Replace allows you to specify whether it should fail if metadata conflicts appear. On Windows operating systems, file metadata include ACLs (Access Control Lists) and other file-dependent information.


The following table lists the parameters expected by this method:

Name Meaning

SourceFileName

The path of the file from which the contents are being copied.

DestinationFileName

The path of the file whose contents are replaced.

DestinationBackupFileName

The path of the backup file created before the replace operation occurs.

IgnoreMetadataErrors

Specifies whether metadata errors are ignored.


Note: Replace raises an exception if the source or destination file does not exist, the paths are invalid, or the user does not have enough privileges to perform the replace operation. If the IgnoreMetadataErrors is set to False, an exception is raised if the metadata merging fails.

Note: Replace is present only on the Windows platform, and can be used only on files that reside on NTFS (New Technology File System) partitions.


See Also