The FileSystemWatcher component provides an interface for monitoring files and directories for modifications. More...
Import Statement: | import ArcGIS.AppFramework.Desktop 1.0 |
Properties
Signals
- fileChanged(string path)
- folderChanged(string path)
Methods
- bool addPath(url pathUrl)
- bool addPath(string path)
- clear()
- bool removePath(url pathUrl)
- bool removePath(string path)
Detailed Description
The following code snippet demonstrates usage of the FileSystemWatcher component. Two file dialogs allow you to select files or folders to watch; after one has been selected, any changes to the paths of the file (or contained files) will be listed in the box labelled 'Changed paths'.
Item { property var changedPaths: [] FileSystemWatcher { id: fileSystemWatcher paths: [ "~" ] onFileChanged: { console.log("onFileChanged", path); changedPaths.unshift(new Date().toString() + ":" + path); changedPathsComboBox.refresh(); } onFolderChanged: { console.log("onFolderChanged", path); changedPaths.unshift(new Date().toString() + ":" + path); changedPathsComboBox.refresh(); } } Column { anchors { fill: parent margins: 10 } spacing: 10 Text { text: "Files being watched" } ComboBox { model: fileSystemWatcher.files } Button { text: "Add File" onClicked: { fileDialog.visible = true; } } Text { text: "Folders being watched" } ComboBox { model: fileSystemWatcher.folders } Button { text: "Add Folder" onClicked: { folderDialog.visible = true; } } Text { text: "Changed paths" } ComboBox { id: changedPathsComboBox width: parent.width model: changedPaths function refresh() { model = []; model = changedPaths; } } } FileDialog { id: fileDialog title: "Choose a file to watch" selectExisting: true nameFilters: [ "All files (*)" ] onAccepted: { fileSystemWatcher.addPath(fileUrl); } } FileDialog { id: folderDialog title: "Choose a folder to watch" selectExisting: true selectFolder: true nameFilters: [ "All files (*)" ] onAccepted: { fileSystemWatcher.addPath(fileUrl); } } }
Property Documentation
Returns a list of files and directories currently being monitored. This list is the combined result of both the 'files' and 'folders' properties.
Signal Documentation
This signal is emitted when the file at the specified path is modified, renamed or removed from disk
Note: The corresponding handler is onFileChanged
.
This signal is emitted when the folder at a specified path, is modified or removed from disk
Note: The corresponding handler is onFolderChanged
.
Method Documentation
Adds path to the file system watcher.
The pathUrl parameter
The URL of the file you're adding.
Adds path to the file system watcher.
The path parameter
The path to the file you're adding.
Removes the specified path from the file system watcher.
The pathUrl parameter
The URL of the path that you're removing.
Removes the specified path from the file system watcher.
The path parameter
A string version of the path that you're removing.