kony.io.File Namespace

The kony,io.File namespace provides functions and properties for doing various operations related on files, such as copying them, renaming them , deleting them, and so on.

Overview

Your app can create a File object to represent files in the device's file system and perform common operations on them. To create a new File object , your app calls the kony.io.File function. Alternatively, it can use the kony.io.FileSystem.getFile function to get an instance of a File object.


var myfile = new kony.io.File("myfile.txt");
or
var myfile = kony.io.FileSystem.getFile("myfile.txt")
File Properties:Name Description
name: [type: String, ReadOnly] Name of the file or directory
fullPath: [type: String, ReadOnly] Full absolute path of the file or directory
parent: [type:kony.io.File, ReadOnly] Returns the parent directory of this file.
This property may return nil or a File object which can neither Readable or Writable, especially in case of Folders which are not accessible by the given Application context
readable: [type: Boolean, ReadOnly] Returns true if this file is readable
writable: [type: Boolean, ReadOnly] Returns true if this file is writable
modificationTime: [type:Number, ReadOnly] Returns the last modification time of the file in UTC
size: [type:Number, ReadOnly Returns the size of a file in number of bytes.
 

The following function is often used in conjunction with the RawBytes object to read data of type RawBytes.

Functions

The kony.io.File namespace contains these functions: To use the copyTo, moveTo, remove, rename, createFile, createDirectory, read, and write File APIs, your app needs runtime permission from the end-user (to perform any of the action correspondent to a file). If you call any API without obtaining the permission, platforms automatically pops up a system permission dialog box with "Allow" and "Deny" options, asking the end-user to grant permission. This is applicable only for the Android platform.

If the end-user taps the "Allow" option, platform proceeds to access the underlying OS API. If the end-user taps the "Deny" option, the PermissionError exception is thrown with the 2300 error code, that means permission is denied.