Provides static methods for the creation, copying, deletion, moving, and opening of files and directories
This class consists exclusively of static methods that operate on files and directories.
All path
parameter is relative to the app data folder which is located at: Android/data/com.kok_emm.mobile/files
Example: You write to a file with the path
"logs.txt" then that file will be available in Android/data/com.kok_emm.mobile/files/logs.txt
static bool writeText(path: string, content: string)
Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten.
Parameters | |
path | The file to write to. |
content | The string to write to the file. |
Return | |
bool | true if success |
static bool writeLines(path: string, lines: string[])
Creates a new file, writes an array of strings to the file, and then closes the file.
Parameters | |
path | The file to write to. |
lines | The lines to write to the file. |
Return | |
bool | true if success |
static bool appendText(path: string, content: string)
Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file.
Parameters | |
path | The file to write to. |
content | The string to write to the file. |
Return | |
bool | true if success |
static bool appendLines(path: string, lines: string[])
Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, writes the specified lines to the file, and then closes the file.
Parameters | |
path | The file to write to. |
lines | The lines to write to the file. |
Return | |
bool | true if success |
static string readText(path: string)
Opens a text file, reads all the text in the file, and then closes the file.
Parameters | |
path | The file to read from. |
Return | |
string | A string containing all the text in the file. null if error |
static string[] readLines(path: string)
Opens a text file, reads all lines of the file, and then closes the file.
Parameters | |
path | The file to read from. |
Return | |
string[] | A string array containing all lines of the file. null if error |
static string separator()
Get the system-dependent default name-separator character.
Return | |
string | The system-dependent default name-separator character |
static bool copy(source: string, destination: string, overwrite: bool = false)
Copies an existing file to a new file.
Parameters | |
source | The file to copy. |
destination | The name of the destination file. This cannot be a directory. |
overwrite | true if the destination file can be overwritten; otherwise, false. |
Return | |
bool | true if success |
static bool delete(path: string)
Deletes the specified file.
Parameters | |
path | The file to delete. |
Return | |
bool | true if success |
static bool exists(path: string)
Determines whether the specified file exists.
Parameters | |
path | The file to check. |
Return | |
bool | true if exists |
static bool isDir(path: string)
Determines whether the specified file is a directory.
Parameters | |
path | The file to check. |
Return | |
bool | true if is a directory |
static bool mkdirs(path: string)
Creates all directories and subdirectories in the specified path unless they already exist.
Parameters | |
path | The directory to create. |
Return | |
bool | true if success |
static string[] list(path: string)
Returns an array of strings naming the files and directories in the directory denoted by this pathname.
Parameters | |
path | The directory to check. |
Return | |
string[] | An array of strings naming the files and directories |
© 2024 - Macrorify by KoK-CODE