FileFolder provides an abstract way to work with the folders in the file system. More...
Import Statement: | import Esri.ArcGISExtras 1.1 |
Since: | Esri.ArcGISExtras 1.0 |
Properties
- exists : bool
- folderName : string
- path : string
Signals
Methods
- bool cd(string folderName)
- bool cdUp()
- bool copyFile(string fileName, string filePath)
- bool fileExists(string fileName)
- FileInfo fileInfo(string fileName)
- list<string> fileNames(list<string> nameFilter, bool subFolders)
- string filePath(string fileName)
- url fileUrl(string fileName)
- FileFolder folder(string folderName)
- list<string> folderNames(const list<string> nameFilter, bool subFolders)
- bool makeFolder()
- bool makePath(string path)
- list<string> readFile(string fileName, jsonobject options)
- jsonObject readJsonFile(string fileName)
- string readTextFile(string fileName)
- string relativeFilePath(string fileName)
- bool removeFile(string fileName)
- bool removeFolder(string folderName, bool recursive)
- bool removeFolder()
- bool removePath(string path)
- bool renameFile(string oldFileName, string newFileName)
- Settings settingsFile(string fileName)
- list<string> writeFile(string fileName, jsonobject content, jsonobject options)
- bool writeJsonFile(string fileName, jsonobject json)
- bool writeTextFile(string fileName, string text)
Detailed Description
FileFolder manipulates path names, accesses information regarding paths, folders and files, and manipulates the underlying file system.
Property Documentation
Returns whether path exists (read-only).
Returns the name of the folder (not the entire path) currently represented by this component (read-only).
A folder with the name mydata
might have a path /home/data/mydata
. If the folder is the root folder then this property is an empty string.
Signal Documentation
Emitted when the exists property of this object changes.
Note: The corresponding handler is onExistsChanged
.
Emitted when the path property of this object changes.
Note: The corresponding handler is onPathChanged
.
Method Documentation
Change the current folder to be the folder specified in folderName. Returns true
if successful; otherwise false
.
Change the current folder to be the parent of the current folder. Returns true
if successful; otherwise false
.
Copies a file to a folder.
- fileName The name of the source file.
- filePath The path and filename of the destination file.
Returns true
if copied successfully; otherwise false
. The source file must exist (of course) and the destination file must not exist. The following code copies a file.
rc = ffCopyTest.copyFile(srcFile1, destFile1);
Gets a list of files in the current folder.
- nameFilter The file names to return.
- subFolders Set to
true
to recurse subfolders.
Gets the clean path to the specified file.
Removes all multiple folder name separators ( /
) and resolves any .
or .
. found in the file path.
Where fileName can be a relative to the current working folder or an absolute reference, this method always returns an absolute reference.
Gets a URL for a specified fileName.
Works for file system paths or references to resource files.
FileFolder folder(string folderName) |
Gets a FileFolder object for the folder specified in folderName.
Gets a list of folders in the current folder.
- nameFilter The folder names to return.
- subFolders Set to
true
to search subfolders.
The following code gets a list of all the folders in the path specified in pathName1
that have a "t" in their names. Subfolders are searched, too.
ffFolderTest.cd(pathName1); var folders = ffFolderTest.folderNames("ff*", true);
Create a new folder corresponding to the path property. Returns true
if folder is created successfully; otherwise false
.
Create a new folder corresponding to the path parameter.
Returns true
if folder is created successfully; otherwise false
.
Read a file.
Returns the file's content as a list of strings.
- fileName The name of the file to read.
- options Specifies the encoding of the returned content.
The following code reads a file and return the content as a text string.
var fileText = ffCopyTest.readTextFile(destFile1);
Read and parse the contents of the JSON file specified by fileName.
Returns an empty string if the file cannot be opened or read or if the content cannot be parsed as JSON.
Read the contents of the text file specified by fileName.
Returns an empty string if the file cannot be opened or read.
Deletes the file corresponding to the fileName parameter.
Returns true
if file is deleted successfully; otherwise false
.
Remove a folder, and optionally all its subfolders.
- folderName The name of the folder to remove.
- recursive Set to
true
to remove folder and all subfolders, otherwise set tofalse
.
Returns true
if successful or the folder does not exist; otherwise false
.
Removes the current folder.
The folder must be empty. Returns true
if successful or the folder does not exist; otherwise false
.
Delete the folder corresponding to the path parameter.
Returns true
if folder is deleted successfully; otherwise false
.
Renames a file from oldFileName to newFileName.
Returns true
if file is renamed successfully; otherwise false
.
This method can be used when moving a file to a different location.
Settings settingsFile(string fileName) |
Gets a Settings object for the setting file.
If the file fileName does not exist, it is created. If fileName is empty, the default file name settings.ini
is used.
Write to file fileName based on content and options parameters.
Write the JSON document json into file specified by fileName.
Returns false
if the output file cannot be opened or if all the data cannot be written to the file.
This method truncates the output file before writing to it.
Write the string in text into the text file specified by fileName.
Returns false
if the output file cannot be opened or if all the data cannot be written to the file.
This method truncates the output file before writing to it.