FOpen Function


Opens or creates a file with the specified filename and returns a handle to the opened file.

If the file name includes a directory name, the file is opened in the specified directory. Otherwise, Silk Performer searches for the file in the directory where the test script is located, in the data directory, in the results directory and in the project directory.

If you are going to use remote agents for the load test, you should store your data files in the Data directory or in the directory where the test script is located. Note that in any case you have to add the data files to your load-testing project.

Include file



FOpen( out hFile       : number,
       in  sFileName   : string,
       in  nAccessMode : number optional,
       in  nOpenMode   : number optional,
       in  nShareMode  : number optional ):boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hFile Variable receiving the file handle.
sFileName Name of the file.

Access options (optional). Possible values are:

  • OPT_FILE_ACCESS_READ. Open the file for reading (default).

  • OPT_FILE_ACCESS_READWRITE. Open the file for reading and writing.


Specifies whether to create or open the file (optional). Possible values are:

  • OPT_FILE_CREATE. Create the file. If the file already exists, it is overwritten.

  • OPT_FILE_OPEN. Open the file (default).

  • OPT_FILE_OPENCREATE. Open the file and create it if it does not exist.


Share options (optional). Possible values are:

  • OPT_FILE_SHARE_NONE. No sharing.

  • OPT_FILE_SHARE_READ. Shared reading access (default).

  • OPT_FILE_SHARE_READWRITE. Shared reading and writing access.


  transaction TMain
    hFile   : number;
    sOutput : string;
    // create new file
    FOpen(hFile, "c:\\temp\\dummyfile.txt", OPT_FILE_ACCESS_READWRITE, OPT_FILE_CREATE);
    write("new file created"); writeln;
    // write string to file
    sOutput := "Hello world!";
    FWrite(hFile, sOutput);
    write("string written to file"); writeln;
    // close file
    write("file closed"); writeln;
  end TMain;


new file created
string written to file
file closed

Sample scripts