Skip to content

PKZip.ZipReader.MoveToPath

Andrew Lambert edited this page Nov 26, 2022 · 3 revisions

PKZip.ZipReader.MoveToPath

Method Signature

 Function MoveToPath(PathName As String, Index As Integer = 0) As Boolean

Parameters

Name Type Comment
PathName String The archive path of the entry to seek to.
Index Integer Optional. If the archive contains more than one entry with the same PathName then this parameter indicates which one you're referring to.

Return value

Returns True if the PathName was found.

Remarks

Finds the PathName in the archive and positions the reader to extract it. If the archive contains more than one item that matches the PathName then you may use the Index parameter to access them all.

If the PathName was not found then the reader's position is returned to where it started.

Example

This example extracts a specific file from an archive and writes it to the user's desktop:

  Dim zipfile As FolderItem = GetOpenFolderItem("") ' the zip archive to read
  Dim zip As New PKZip.ZipReader(zipfile)
  If zip.MoveToPath("path/to/the/file.txt") Then
    ' we found the file. Extract it into the output stream
    Dim outputfile As FolderItem = SpecialFolder.Desktop.Child("file.txt")
    Dim output As BinaryStream = BinaryStream.Create(outputfile)
    Call zip.MoveNext(output)
    output.Close
  End If
  zip.Close

Entry-level points of interest denoted by "☜"



Clone this wiki locally