meta data for this page
  •  

ibec_fs_OpenFile

Opens a file for reading or writing.

Description

The ibec_fs_OpenFile function opens file specified by FileName for reading or writing.

The Mode parameter indicates how the file is to be opened. The Mode parameter consists of an open mode and a share mode stored together. The open mode must be one of the following values:

 ^  Value              ^    Meaning                                                                                                ^
 
 |  __fmCreate         |    Create a file with the given name. If a file with the given name exists, open the file in write mode.  |
 |  __fmOpenRead       |    Open the file for reading only.                                                                        |
 |  __fmOpenWrite      |    Open the file for writing only. Writing to the file completely replaces the current contents.          |
 |  __fmOpenReadWrite  |    Open the file to modify the current contents rather than replace them.                                 |

The share mode must be one of the following values:

 ^ Value               ^ Meaning                                                                                     ^
 
 | __fmShareCompat     | Sharing is compatible with the way FCBs are opened.                                         |
 | __fmShareExclusive  | Other applications can not open the file for any reason.                                    |
 | __fmShareDenyWrite  | Other applications can open the file for reading but not for writing.                       |
 | __fmShareDenyRead   | Other applications can open the file for writing but not for reading.                       |
 | __fmShareDenyNone   | No attempt is made to prevent other applications from reading from or writing to the file.  |

If the file cannot be opened, ibec_fs_OpenFile returns NULL. Otherwise it returns the handle for the file just opened.

To close the file opened with ibec_fs_OpenFile use the ibec_fs_CloseFile function.

GThis function now supports files larger than 2 GB and Unicode (UTF8) file names. You can still use ANSI names, necessary checks and conversion are performed automatically.

Syntax

   function ibec_fs_OpenFile(FileName : string; Mode : integer): variant;

Example

execute  IBEBlock
as
begin
  FileName = 'C:\mydata.txt';
  FH = ibec_fs_OpenFile(FileName, __fmCreate);
  if (not FH is NULL) then
  begin
    ibec_fs_Writeln(FH, 'just a test');
    ibec_fs_CloseFile(FH);
  end
end