Show: Delphi C++
Display Preferences

System.IOUtils.TFile

From XE2 API Documentation
Jump to: navigation, search

Delphi

  TFile = record
  private
    const
      FCMinFileNameLen = 12;
    class procedure InternalCheckFilePathParam(const Path: string;
        const FileExistsCheck: Boolean); static;
    class procedure CheckAppendAllTextParameters(const Path: string;
        const Encoding: TEncoding; const NeedEncoding: Boolean); static;
    class procedure CheckAppendTextParameters(const Path: string); inline; static;
    class procedure CheckCopyParameters(const SourceFileName,
        DestFileName: string; const Overwrite: Boolean); static;
    class procedure CheckCreateParameters(const Path: string); inline; static;
    class procedure CheckCreateTextParameters(const Path: string); inline; static;
{$IFDEF MSWINDOWS}
    class procedure CheckDecryptParameters(const Path: string); inline; static;
{$ENDIF MSWINDOWS}
    class procedure CheckDeleteParameters(const Path: string); inline; static;
{$IFDEF MSWINDOWS}
    class procedure CheckEncryptParameters(const Path: string); inline; static;
{$ENDIF MSWINDOWS}
    class procedure CheckGetAttributesParameters(const Path: string); inline; static;
    class procedure CheckGetCreationTimeParameters(const Path: string); inline; static;
    class procedure CheckGetCreationTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckGetLastAccessTimeParameters(const Path: string); inline; static;
    class procedure CheckGetLastAccessTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckGetLastWriteTimeParameters(const Path: string); inline; static;
    class procedure CheckGetLastWriteTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckMoveParameters(const SourceFileName,
        DestFileName: string); static;
    class procedure CheckOpenParameters(const Path: string); inline; static;
    class procedure CheckOpenReadParameters(const Path: string); inline; static;
    class procedure CheckOpenTextParameters(const Path: string); inline; static;
    class procedure CheckOpenWriteParameters(const Path: string); inline; static;
    class procedure CheckReadAllBytesParameters(const Path: string); inline; static;
    class procedure CheckReadAllLinesParameters(const Path: string;
        const Encoding: TEncoding; const NeedEncoding: Boolean); static;
    class procedure CheckReadAllTextParameters(const Path: string;
        const Encoding: TEncoding; const NeedEncoding: Boolean); static;
{$IFDEF MSWINDOWS}
    class procedure CheckReplaceParameters(const SourceFileName,
        DestinationFileName, DestinationBackupFileName: string); static;
{$ENDIF MSWINDOWS}
    class procedure CheckSetAttributesParameters(const Path: string); inline; static;
    class procedure CheckSetCreationTimeParameters(const Path: string); inline; static;
    class procedure CheckSetCreationTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckSetLastAccessTimeParameters(const Path: string); inline; static;
    class procedure CheckSetLastAccessTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckSetLastWriteTimeParameters(const Path: string); inline; static;
    class procedure CheckSetLastWriteTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckWriteAllBytesParameters(const Path: string); inline; static;
    class procedure CheckWriteAllLinesParameters(const Path: string;
        const Encoding: TEncoding; const NeedEncoding: Boolean); static;
    class procedure CheckWriteAllTextParameters(const Path: string;
        const Encoding: TEncoding; const NeedEncoding: Boolean); static;
    class function GetEncoding(const Stream: TStream): TEncoding; static;
    class function GetStringArrayFromText(const Text: string): TStringDynArray; static;
    class function GetStringListFromArray(const AnArray: TStringDynArray): TStringList; static;
    class function DoCreateOpenFile(const Path: string): TFileStream; static;
    class function DoCopy(const SourceFileName, DestFileName: string;
        const Overwrite: Boolean): Boolean; inline; static;
    class function DoGetAttributes(const Path: string; FollowLink: Boolean = True): TFileAttributes; {$IFDEF MSWINDOWS}inline;{$ENDIF} static;
    class function DoReadAllBytes(const Path: string): TBytes; static;
    class function DoReadAllText(const Path: string): string; overload; static;
    class function DoReadAllText(const Path: string;
        const Encoding: TEncoding): string; overload; static;
    class procedure DoSetAttributes(const Path: string;
        const Attributes: TFileAttributes); {$IFDEF MSWINDOWS}inline;{$ENDIF} static;
    class procedure DoWriteAllText(const Path, Contents: string;
        const Encoding: TEncoding; const WriteBOM: Boolean); static;
    class procedure DoWriteAllLines(const Path: string;
        const Contents: TStringDynArray; const Encoding: TEncoding;
        const WriteBOM: Boolean); static;
    class function IntegerToFileAttributes(const Attributes: Integer): TFileAttributes; static;
    class function FileAttributesToInteger(const Attributes: TFileAttributes): Integer; static;
  public
    class function Create(const Path: string): TFileStream; overload; inline; static;
    class function Create(const Path: string; const BufferSize: Integer): TFileStream; overload; static;
    class procedure AppendAllText(const Path, Contents: string); overload; static;
    class procedure AppendAllText(const Path, Contents: string;
        const Encoding: TEncoding); overload; static;
    class function AppendText(const Path: string): TStreamWriter; static;
    class procedure Copy(const SourceFileName, DestFileName: string);
        overload; inline; static;
    class procedure Copy(const SourceFileName, DestFileName: string;
        const Overwrite: Boolean); overload; static;
    class function CreateSymLink(const Link, Target: string): Boolean; static;
    class function CreateText(const Path: string): TStreamWriter; static;
{$IFDEF MSWINDOWS}
    class procedure Decrypt(const Path: string); static;
{$ENDIF MSWINDOWS}
    class procedure Delete(const Path: string); static;
{$IFDEF MSWINDOWS}

C++

struct DECLSPEC_DRECORD TFile{
private:
static const System::Int8 FCMinFileNameLen = System::Int8(0xc);
static void __fastcall InternalCheckFilePathParam(const System::UnicodeString Path, const bool FileExistsCheck);
static void __fastcall CheckAppendAllTextParameters(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding, const bool NeedEncoding);
static void __fastcall CheckAppendTextParameters(const System::UnicodeString Path);
static void __fastcall CheckCopyParameters(const System::UnicodeString SourceFileName, const System::UnicodeString DestFileName, const bool Overwrite);
static void __fastcall CheckCreateParameters(const System::UnicodeString Path);
static void __fastcall CheckCreateTextParameters(const System::UnicodeString Path);
static void __fastcall CheckDecryptParameters(const System::UnicodeString Path);
static void __fastcall CheckDeleteParameters(const System::UnicodeString Path);
static void __fastcall CheckEncryptParameters(const System::UnicodeString Path);
static void __fastcall CheckGetAttributesParameters(const System::UnicodeString Path);
static void __fastcall CheckGetCreationTimeParameters(const System::UnicodeString Path);
static void __fastcall CheckGetCreationTimeUtcParameters(const System::UnicodeString Path);
static void __fastcall CheckGetLastAccessTimeParameters(const System::UnicodeString Path);
static void __fastcall CheckGetLastAccessTimeUtcParameters(const System::UnicodeString Path);
static void __fastcall CheckGetLastWriteTimeParameters(const System::UnicodeString Path);
static void __fastcall CheckGetLastWriteTimeUtcParameters(const System::UnicodeString Path);
static void __fastcall CheckMoveParameters(const System::UnicodeString SourceFileName, const System::UnicodeString DestFileName);
static void __fastcall CheckOpenParameters(const System::UnicodeString Path);
static void __fastcall CheckOpenReadParameters(const System::UnicodeString Path);
static void __fastcall CheckOpenTextParameters(const System::UnicodeString Path);
static void __fastcall CheckOpenWriteParameters(const System::UnicodeString Path);
static void __fastcall CheckReadAllBytesParameters(const System::UnicodeString Path);
static void __fastcall CheckReadAllLinesParameters(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding, const bool NeedEncoding);
static void __fastcall CheckReadAllTextParameters(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding, const bool NeedEncoding);
static void __fastcall CheckReplaceParameters(const System::UnicodeString SourceFileName, const System::UnicodeString DestinationFileName, const System::UnicodeString DestinationBackupFileName);
static void __fastcall CheckSetAttributesParameters(const System::UnicodeString Path);
static void __fastcall CheckSetCreationTimeParameters(const System::UnicodeString Path);
static void __fastcall CheckSetCreationTimeUtcParameters(const System::UnicodeString Path);
static void __fastcall CheckSetLastAccessTimeParameters(const System::UnicodeString Path);
static void __fastcall CheckSetLastAccessTimeUtcParameters(const System::UnicodeString Path);
static void __fastcall CheckSetLastWriteTimeParameters(const System::UnicodeString Path);
static void __fastcall CheckSetLastWriteTimeUtcParameters(const System::UnicodeString Path);
static void __fastcall CheckWriteAllBytesParameters(const System::UnicodeString Path);
static void __fastcall CheckWriteAllLinesParameters(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding, const bool NeedEncoding);
static void __fastcall CheckWriteAllTextParameters(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding, const bool NeedEncoding);
static System::Sysutils::TEncoding* __fastcall GetEncoding(const System::Classes::TStream* Stream);
static ::System::TStringDynArray __fastcall GetStringArrayFromText(const System::UnicodeString Text);
static System::Classes::TStringList* __fastcall GetStringListFromArray(const ::System::TStringDynArray AnArray);
static System::Classes::TFileStream* __fastcall DoCreateOpenFile(const System::UnicodeString Path);
static bool __fastcall DoCopy(const System::UnicodeString SourceFileName, const System::UnicodeString DestFileName, const bool Overwrite);
static TFileAttributes __fastcall DoGetAttributes(const System::UnicodeString Path, bool FollowLink = true);
static System::DynamicArray<System::Byte> __fastcall DoReadAllBytes(const System::UnicodeString Path);
static System::UnicodeString __fastcall DoReadAllText(const System::UnicodeString Path)/* overload */;
static System::UnicodeString __fastcall DoReadAllText(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding)/* overload */;
static void __fastcall DoSetAttributes(const System::UnicodeString Path, const TFileAttributes Attributes);
static void __fastcall DoWriteAllText(const System::UnicodeString Path, const System::UnicodeString Contents, const System::Sysutils::TEncoding* Encoding, const bool WriteBOM);
static void __fastcall DoWriteAllLines(const System::UnicodeString Path, const ::System::TStringDynArray Contents, const System::Sysutils::TEncoding* Encoding, const bool WriteBOM);
static TFileAttributes __fastcall IntegerToFileAttributes(const int Attributes);
static int __fastcall FileAttributesToInteger(const TFileAttributes Attributes);
public:
static System::Classes::TFileStream* __fastcall Create(const System::UnicodeString Path)/* overload */;
static System::Classes::TFileStream* __fastcall Create(const System::UnicodeString Path, const int BufferSize)/* overload */;
static void __fastcall AppendAllText(const System::UnicodeString Path, const System::UnicodeString Contents)/* overload */;
static void __fastcall AppendAllText(const System::UnicodeString Path, const System::UnicodeString Contents, const System::Sysutils::TEncoding* Encoding)/* overload */;
static System::Classes::TStreamWriter* __fastcall AppendText(const System::UnicodeString Path);
static void __fastcall Copy(const System::UnicodeString SourceFileName, const System::UnicodeString DestFileName)/* overload */;
static void __fastcall Copy(const System::UnicodeString SourceFileName, const System::UnicodeString DestFileName, const bool Overwrite)/* overload */;
static bool __fastcall CreateSymLink(const System::UnicodeString Link, const System::UnicodeString Target);
static System::Classes::TStreamWriter* __fastcall CreateText(const System::UnicodeString Path);
static void __fastcall Decrypt(const System::UnicodeString Path);
static void __fastcall Delete(const System::UnicodeString Path);
static void __fastcall Encrypt(const System::UnicodeString Path);
static bool __fastcall Exists(const System::UnicodeString Path, bool FollowLink = true);
static TFileAttributes __fastcall GetAttributes(const System::UnicodeString Path, bool FollowLink = true);
static System::TDateTime __fastcall GetCreationTime(const System::UnicodeString Path);
static System::TDateTime __fastcall GetCreationTimeUtc(const System::UnicodeString Path);
static System::TDateTime __fastcall GetLastAccessTime(const System::UnicodeString Path);
static System::TDateTime __fastcall GetLastAccessTimeUtc(const System::UnicodeString Path);
static System::TDateTime __fastcall GetLastWriteTime(const System::UnicodeString Path);
static System::TDateTime __fastcall GetLastWriteTimeUtc(const System::UnicodeString Path);
static bool __fastcall GetSymLinkTarget(const System::UnicodeString FileName, System::Sysutils::TSymLinkRec &SymLinkRec)/* overload */;
static bool __fastcall GetSymLinkTarget(const System::UnicodeString FileName, System::UnicodeString &TargetName)/* overload */;
static void __fastcall Move(System::UnicodeString SourceFileName, System::UnicodeString DestFileName);
static System::Classes::TFileStream* __fastcall Open(const System::UnicodeString Path, const TFileMode Mode)/* overload */;
static System::Classes::TFileStream* __fastcall Open(const System::UnicodeString Path, const TFileMode Mode, const TFileAccess Access)/* overload */;
static System::Classes::TFileStream* __fastcall Open(const System::UnicodeString Path, const TFileMode Mode, const TFileAccess Access, const TFileShare Share)/* overload */;
static System::Classes::TFileStream* __fastcall OpenRead(const System::UnicodeString Path);
static System::Classes::TStreamReader* __fastcall OpenText(const System::UnicodeString Path);
static System::Classes::TFileStream* __fastcall OpenWrite(const System::UnicodeString Path);
static System::DynamicArray<System::Byte> __fastcall ReadAllBytes(const System::UnicodeString Path);
static ::System::TStringDynArray __fastcall ReadAllLines(const System::UnicodeString Path)/* overload */;
static ::System::TStringDynArray __fastcall ReadAllLines(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding)/* overload */;
static System::UnicodeString __fastcall ReadAllText(const System::UnicodeString Path)/* overload */;
static System::UnicodeString __fastcall ReadAllText(const System::UnicodeString Path, const System::Sysutils::TEncoding* Encoding)/* overload */;
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 */;
static void __fastcall SetAttributes(const System::UnicodeString Path, const TFileAttributes Attributes);
static void __fastcall SetCreationTime(const System::UnicodeString Path, const System::TDateTime CreationTime);
static void __fastcall SetCreationTimeUtc(const System::UnicodeString Path, const System::TDateTime CreationTime);
static void __fastcall SetLastAccessTime(const System::UnicodeString Path, const System::TDateTime LastAccessTime);
static void __fastcall SetLastAccessTimeUtc(const System::UnicodeString Path, const System::TDateTime LastAccessTime);
static void __fastcall SetLastWriteTime(const System::UnicodeString Path, const System::TDateTime LastWriteTime);
static void __fastcall SetLastWriteTimeUtc(const System::UnicodeString Path, const System::TDateTime LastWriteTime);
static void __fastcall WriteAllBytes(const System::UnicodeString Path, const System::DynamicArray<System::Byte> Bytes);
static void __fastcall WriteAllLines(const System::UnicodeString Path, const ::System::TStringDynArray Contents)/* overload */;
static void __fastcall WriteAllLines(const System::UnicodeString Path, const ::System::TStringDynArray Contents, const System::Sysutils::TEncoding* Encoding)/* overload */;
static void __fastcall WriteAllText(const System::UnicodeString Path, const System::UnicodeString Contents)/* overload */;
static void __fastcall WriteAllText(const System::UnicodeString Path, const System::UnicodeString Contents, const System::Sysutils::TEncoding* Encoding)/* overload */;
};

Properties

Type Visibility Source Unit Parent
struct
class
public
System.IOUtils.pas
System.IOUtils.hpp
System.IOUtils System.IOUtils

Description

Contains a large number of static utility methods used in file manipulations.

TFile is a record containing only static methods used to perform various operations on files. Do not declare variables of type TFile, since TFile has no instance methods or fields. Operations that can be carried out using TFile include:

  • Creating, renaming, and deleting files
  • Simplified access to file contents
  • Manipulating file attributes and timestamps
Note: Most of the methods exposed by TFile are signature-compatible with the ones exposed by the File class in the .NET Framework.

See Also

Personal tools
Previous Versions
Translations