Skip To Content ArcGIS for Developers Sign In Dashboard

FileFolder QML Type

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

Signals

Methods

Detailed Description

FileFolder manipulates path names, accesses information regarding paths, folders and files, and manipulates the underlying file system.

Property Documentation

exists : bool

Returns whether path exists (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(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(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(fileName)

Returns true if the file specified in fileName exists.


FileInfo fileInfo(fileName)

Gets a FileInfo object for the file specified in fileName.


list<string> fileNames(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(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(fileName)

Gets a URL for a specified fileName.

Works for file system paths or references to resource files.


FileFolder folder(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(path)

Create a new folder corresponding to the path parameter.

Returns true if folder is created successfully; otherwise false.


list<string> readFile(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(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(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(fileName)

Gets the relative file path for fileName.


bool removeFile(fileName)

Deletes the file corresponding to the fileName parameter.

Returns true if file is deleted successfully; otherwise false.


bool removeFolder(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 to false.

Returns true if successful or the folder does not exist; 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 removePath(path)

Delete the folder corresponding to the path parameter.

Returns true if folder is deleted successfully; otherwise false.


bool renameFile(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(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(fileName, jsonobject content, jsonobject options)

Write to file fileName based on content and options parameters.


bool writeJsonFile(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(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.



Feedback on this topic?