Add files to create a zip file. More...
Import Statement: | import ArcGIS.AppFramework 1.0 |
Inherits: |
Properties
- path : string
Methods
- bool addFile(string filePath)
- bool addFile(string filePath, string archivedFilePath)
- bool addFile(string filePath, string archivedFilePath, string comment)
- bool addFile(string filePath, string archivedFilePath, string comment, bool append)
- close()
Detailed Description
The ZipWriter component is primarily used to add files to a zip archive. This should ideally be implemented along with ZipReader and ZipFileInfo, as ZipWriter contains no means to read the archive it writes to.
This sample demonstrates usage of the ZipWriter component, giving the user two buttons that open file dialogs; one to define the new or existing zip archive to write to, one to select files to add to it. The ZipReader component is used to display the files as they are added.
Item { ZipReader { id: zipReader } ZipWriter { id: zipWriter } Grid { columns: 2 spacing: 5 anchors { left: parent.left right: parent.right top: titleText.bottom bottom: parent.bottom margins: 10 } Button { text: "Path" onClicked: { fileDialog.open(); } } Text { text: zipReader.path } Label { text: "Folders" } ComboBox { model: zipReader.folderNames } Label { text: "Files" } ComboBox { model: zipReader.fileNames } Button { text: "Add File" onClicked: { addFileDialog.open(); } } } FileDialog { id: fileDialog title: "Choose a ZIP archive" selectExisting: false selectMultiple: false nameFilters: [ "ZIP archives (*.zip)", "All files (*)" ] onAccepted: { console.log("ZIP archive url: " + fileDialog.fileUrl) zipReader.path = AppFramework.urlInfo(fileDialog.fileUrl).localFile; zipWriter.path = zipReader.path; } } FileDialog { id: addFileDialog title: "Choose a file to archive" selectExisting: true selectMultiple: false nameFilters: [ "All files (*)" ] onAccepted: { console.log("ZIP archive url: " + addFileDialog.fileUrl) var path = AppFramework.urlInfo(addFileDialog.fileUrl).localFile; zipWriter.addFile(path); zipReader.refresh(); } } }
Property Documentation
Method Documentation
Adds or copies a file to the current zip archive. Returns true if successful.
The filePath parameter
The path of the file to be added. For example, C:\Testing
ZipWriterAppStudio.txt
Adds or copies a file to the current zip archive with a new path. Returns true if successful.
The filePath parameter
The path to the file you're adding to the zip archive. For example, C:\Testing
ZipWriterAppStudio.txt
The archivedFilePath parameter
The file's new path within the zip archive. For example, defining as DataAppStudio_New.txt would add the file to the zip archive as AppStudio_New.txt, inside a subfolder named Data.
Adds or copies a file to the current zip archive with a new path and with the provided comment. Returns true if successful.
The filePath parameter
The path to the file you're adding to the zip archive.
The archivedFilePath parameter
The file's new path within the zip archive. For example, defining as DataAppStudio_New.txt would add the file to the zip archive as AppStudio_New.txt, inside a subfolder named Data.
The comment parameter
A printable string to associate with the file.
Adds a file from the given filePath to the new archivedFilePath, with the provided comment. If files already exist in the archive, applies the specified append behavior.
The filePath parameter
The path to the file to add to the zip archive.
The archivedFilePath parameter
The file's new path within the zip archive. For example, defining as DataAppStudio_New.txt would add the file to the zip archive as AppStudio_New.txt, inside a subfolder named Data.
The comment parameter
A printable string to associate with the file.
The append parameter
If true, adds the file to the zip archive. If false, replaces the existing files with a new file.