FileOpen()

Opens an file to read, write, or append.

FileOpen( file=string, mode=string, charset=string, seekable=boolean );

Returns: any

Argument Description Default
file
string, required

a file path

Alias: path, filepath, source

mode
string, optional

Action to perform on the file, including the following:

  • read
  • readBinary
  • write
  • append

If you do not specify the mode, Lucee opens the file in read mode.

read

charset
string, optional

The character set of the file.

seekable
boolean, optional

can be used for function fileseek

Examples

myFile = fileOpen("filepath/filename.ext");
writeDump(myfile);
// how to access the underlying resource provider info
f = "ram://demo.txt";
fileWrite(f, "demo");
dump(f.getResource().getResourceProvider().getScheme()); // ram ( i.e. the resource provider type)

See also