System.IOUtils.TFile.WriteAllText
Delphi
class procedure WriteAllText(const Path, Contents: string); overload; static;
class procedure WriteAllText(const Path, Contents: string; const Encoding: TEncoding); overload; static;
C++
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, System::Sysutils::TEncoding* const Encoding)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | System.IOUtils.pas System.IOUtils.hpp |
System.IOUtils | TFile |
Description
Writes a given text to a file.
Use WriteAllText to write a given text to a file. If the file specified by the Path parameter exists, it is overwritten; otherwise the file is created and filled with the given text. The following table lists the parameters expected by this method.
Name | Meaning |
---|---|
Path |
The path to the file. |
Contents |
The string containing the text to be written. |
Encoding |
The encoding used for the text |
Note: WriteAllText raises an exception if the file cannot be accessed or the path is invalid.
See Also
Code Examples