File.Create

Top  Previous  Next

 

Syntax

function File.Create(Filename: string; Encoding: integer): pointer

 

Description

Create a new file with the given Filename making it ready for reading and writing. If a file with the given name exists, this file is overwritten.

 

The Encoding parameter is one of the following:

__encNONE

No encoding, used for binary streams.

__encANSI

No specific encoding, using the system code page.

__encUTF8

UTF8 encoding.

__encUTF16

UTF16 or Unicode encoding.

__encUTF16BE

Big-endian UTF16 or Unicode encoding.

 

The Return value is a file-stream pointer that can be used for additional calls. If file creation fails, NULL is returned.

 

After successful file creation, the "encoding preamble" is written to the file.

 

See also

File.Close

 

Example

execute udsblock

as

begin

  /* create a text file with UTF8 encoding */ 

  fs = File.Create('c:\data\utf8text.txt', __encUTF8);

  try

    /* write line of text */

    File.WriteLn(fs, 'this is a line of text');

  finally

    File.Close(fs);

  end

end