File.SetSize

Top  Previous  Next

 

Syntax

function File.SetSize(F: pointer; NewSize: large-integer): integer

 

Alternative Names

ibec_fs_SetSize

 

Description

Modifies the size of the given file-stream and sets it to NewSize bytes. If the existing file was larger, it's truncated, if it's smaller, it is extended.

 

Always Returns zero.

 

See also

File.Create
File.GetSize
File.Seek

 

Example

execute udsblock

as

begin

  /* create a file that will be 1GB in size */ 

  fs = File.Create('c:\data\sample.dat, __encNONE);

  try

    /* make sure the file is 1 GB in size */

    File.SetSize(fs, 1024 * 1024 * 1024);

    /* go back to the beginning */

    File.Seek(fs, 0, __soFromBeginning);

 

    /* ... write data ... */

  finally

    File.Close(fs);

  end

end