File Class
Represents a file or folder in the virtual file-system. This file/folder may not yet exist. It is returned from system.getFile function of the 'system' global variable.
Item Index
Methods
Methods
copyTo
-
toPath
Copy this file to the given destination.
Parameters:
-
toPath
StringPath to copy this file to.
createFile
()
Create an empty file at the location defined by this File object.
createFolder
()
Create a folder at the path represented by this File object.
exists
()
Boolean
Does this file or folder exist?
Returns:
getFiles
()
File[]
Returns an array of File objects representing the contents of this folder. Throws an exception if this File object is not a folder.
Returns:
getParent
()
File
Return a File object representing the parent-folder of this File object.
Returns:
moveTo
-
toPath
Move this file to the given path.
Parameters:
-
toPath
StringPath to move this file to.
readBase64
()
String
Reads the contents of the file an returns it as a base64 encoded string.
This only works for files up to 100kB.
Returns:
readLines
-
numLines
Returns the given number of lines (or all lines if numLines=0) as an array of strings.
Parameters:
-
numLines
Object
Returns:
readObject
()
Object
Parses the contents of the file as JSON and returns a Javascript object. This only works for files up to 100kB.
Returns:
readText
()
String
Returns the contents of this file as a string. This only works for files up to 100kB.
Returns:
remove
()
Delete the file or folder at the path represented by this File object.
removeFile
()
Delete the file at the path represented by this File object. Fails if this is a folder.
removeFolder
-
[recursive=false]
Delete the folder at the path represented by this File object. Fails if this is a file.
Parameters:
-
[recursive=false]
String optionalRemove this folder.
rename
-
newName
Rename the current file to the given name.
Parameters:
-
newName
StringNew name of file.
Returns:
toURL
()
String
Get the URL that this file is accessible at.
Returns:
writeBase64
-
base64String
Parses the given base64-encoded string and writes the result to the file.
Parameters:
-
base64String
Stringbase64 encoding of what is to be written to the file.
Returns:
writeObject
-
object
Write the given object to the file in JSON format.
Parameters:
-
object
StringObject to write to the file.
Returns:
writeText
-
text
Write the given text to this file.
Parameters:
-
text
StringText to write to the file.
Returns:
Properties
canList
Boolean
Does the current user have permission to list this folder?
canRead
Boolean
Does the current user have permission to read this file?
canWrite
Boolean
Does the current user have permission to write to this file?
extension
String
Extension of the file.
fullPath
String
The absolute path of the file.
isExecutable
Boolean
Is this file an executable?
isFile
Boolean
Is this a file?
isFolder
Boolean
Is this a folder?
isLengthKnown
Boolean
Is the length of this file known?
isVirtualFileSystemFolder
Boolean
Is this file a folder in the virtual file-system?
length
Number
Length of the file in bytes.
modifiedTime
Date
Date and time that this file/folder was last modified.
name
String
The name of the file.