This documentation is archived and is not being maintained.

PackagePart.GetStream Method ()

Returns the part content data stream.

Namespace: System.IO.Packaging
Assembly: WindowsBase (in windowsbase.dll)

public Stream GetStream ()
public Stream GetStream ()
public function GetStream () : Stream
You cannot use methods in XAML.

Return Value

The content data stream for the part.

Exception typeCondition

InvalidOperationException

The part has been deleted.

-or-

The Package is not open (Dispose or Close has been called).

IOException

The stream object returned by the GetStreamCore method of the derived subclass is a null reference (Nothing in Visual Basic).

This method opens the content stream with FileMode of OpenOrCreate and FileAccess permissions that are the same as the parent Package.

The overload GetStream method allows you to set a specific FileMode.

Notes to Callers: GetStream internally calls the derived GetStreamCore method to actually open and return the part data stream based on the physical format implemented in the derived class. By default, the ZipPackagePart subclass implementation of the abstract PackagePart class is provided and used. In the default operation, GetStream internally calls GetStreamCore of the ZipPackagePart class to open and return the part data stream from a ZIP file.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: