Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ZipArchiveEntry.Open Method

.NET Framework 4.6 and 4.5

Opens the entry from the zip archive.

Namespace:  System.IO.Compression
Assembly:  System.IO.Compression (in System.IO.Compression.dll)

Public Function Open As Stream

Return Value

Type: System.IO.Stream
The stream that represents the contents of the entry.


The entry is already currently open for writing.


The entry has been deleted from the archive.


The archive for this entry was opened with the Create mode, and this entry has already been written to.


The entry is either missing from the archive or is corrupt and cannot be read.


The entry has been compressed by using a compression method that is not supported.


The zip archive for this entry has been disposed.

You use this method to access the stream for an entry in a zip archive. After retrieving the stream, you can read from or write to the stream. When you write to the stream, the modifications you make to the entry will appear in the zip archive.

The following example shows how to create a new entry, open it with the Open method, and write to the stream.

Imports System.IO
Imports System.IO.Compression

Module Module1

    Sub Main()
        Using zipToOpen As FileStream = New FileStream("c:\users\exampleuser\release.zip", FileMode.Open)
            Using archive As ZipArchive = New ZipArchive(zipToOpen, ZipArchiveMode.Update)
                Dim readmeEntry As ZipArchiveEntry = archive.CreateEntry("Readme.txt")
                Using writer As StreamWriter = New StreamWriter(readmeEntry.Open())
                    writer.WriteLine("Information about this package.")
                End Using 
            End Using 
        End Using 
    End Sub 

End Module

.NET Framework

Supported in: 4.6, 4.5

Supported in: Windows Phone 8.1
© 2015 Microsoft