top

openCommonFile

Published 2014-10-28 | (Compatible with SDK 2.5,3.5,4.5,5.0,5.1 and 2010,2011,2012,2013,2014 models)

Opens files in common storage area of an application.

The openCommonFile class opens files in common storage area of an application.

openCommonFile
Syntax fileSystemObj.openCommonFile(filePath, mode);
Parameter
filePath (String)
path including a file name.
mode (String)
  • r : Open a file for reading. The file must exist.
  • w : Create an empty file for writing. If a file with the same name already exists, its content is erased and the file is treated as a new empty file.
  • a : Append to a file. Writing operations append data at the end of the file. The file is created if it does not exist.
  • r+ : Open a file for update (both reading and writing). The file must exist.
  • w+ : Create an empty file for both reading and writing. If a file with the same name already exists, its content is erased and the file is treated as a new empty file.
  • a+ : Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content from being overwritten.
Return Value Browser file object
Remarks With this method, all the applications operate on input and output files in the same area. Due to this feature, files used in other applications can have the same name. It is required to create directories using application ID via curWidget.id and execute file operations in the directory.
Example
var fileSystemObj = new FileSystem();
var fileObj = fileSystemObj.openCommonFile(curWidget.id + '/testFile.data', 'w');
    fileObj.writeAll('something to write.');
    fileSystemObj.closeCommonFile(fileObj);
Enumeration None