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()
- bool removeFolder(string folderName, bool recursive)
- 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
[read-only] exists : bool |
Returns whether path exists (read-only).
[read-only] folderName : string |
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.
path : string |
The complete path currently represented by this object.
Signal Documentation
existsChanged() |
Emitted when the exists property of this object changes.
Note: The corresponding handler is onExistsChanged
.
pathChanged() |
Emitted when the path property of this object changes.
Note: The corresponding handler is onPathChanged
.
Method Documentation
bool cd(string folderName) |
Change the current folder to be the folder specified in folderName. Returns true
if successful; otherwise false
.
bool cdUp() |
Change the current folder to be the parent of the current folder. Returns true
if successful; otherwise false
.
bool copyFile(string fileName, string filePath) |
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);
bool fileExists(string fileName) |
Returns true if the file specified in fileName exists.
list<string> fileNames(list<string> nameFilter, bool subFolders) |
Gets a list of files in the current folder.
- nameFilter The file names to return.
- subFolders Set to
true
to recurse subfolders.
string filePath(string fileName) |
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.
url fileUrl(string fileName) |
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.
list<string> folderNames(const list<string> nameFilter, bool subFolders) |
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);
bool makeFolder() |
Create a new folder corresponding to the path property. Returns true
if folder is created successfully; otherwise false
.
bool makePath(string path) |
Create a new folder corresponding to the path parameter.
Returns true
if folder is created successfully; otherwise false
.
list<string> readFile(string fileName, jsonobject options) |
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);
jsonObject readJsonFile(string fileName) |
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.
string readTextFile(string fileName) |
Read the contents of the text file specified by fileName.
Returns an empty string if the file cannot be opened or read.
string relativeFilePath(string fileName) |
Gets the relative file path for fileName.
bool removeFile(string fileName) |
Deletes the file corresponding to the fileName parameter.
Returns true
if file is deleted successfully; otherwise false
.
bool removeFolder() |
Removes the current folder.
The folder must be empty. Returns true
if successful or the folder does not exist; otherwise false
.
bool removeFolder(string folderName, bool recursive) |
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
.
bool removePath(string path) |
Delete the folder corresponding to the path parameter.
Returns true
if folder is deleted successfully; otherwise false
.
bool renameFile(string oldFileName, string newFileName) |
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.
list<string> writeFile(string fileName, jsonobject content, jsonobject options) |
Write to file fileName based on content and options parameters.
bool writeJsonFile(string fileName, jsonobject json) |
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.
bool writeTextFile(string fileName, string text) |
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.