PackagePart.GetStream Method

Definition

Returns the part content data stream.

Overloads

GetStream()

Returns the part content data stream.

GetStream(FileMode)

Returns the content stream opened in a specified I/O FileMode.

GetStream(FileMode, FileAccess)

Returns the part content stream opened with a specified FileMode and FileAccess.

GetStream()

Source:
PackagePart.cs
Source:
PackagePart.cs
Source:
PackagePart.cs

Returns the part content data stream.

public:
 System::IO::Stream ^ GetStream();
public System.IO.Stream GetStream ();
member this.GetStream : unit -> System.IO.Stream
Public Function GetStream () As Stream

Returns

The content data stream for the part.

Exceptions

The part has been deleted.

-or-

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

The stream object returned by the GetStreamCore(FileMode, FileAccess) method of the derived subclass is null.

Remarks

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(FileMode, FileAccess) 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(FileMode, FileAccess) of the ZipPackagePart class to open and return the part data stream from a ZIP file.

Applies to

GetStream(FileMode)

Source:
PackagePart.cs
Source:
PackagePart.cs
Source:
PackagePart.cs

Returns the content stream opened in a specified I/O FileMode.

public:
 System::IO::Stream ^ GetStream(System::IO::FileMode mode);
public System.IO.Stream GetStream (System.IO.FileMode mode);
member this.GetStream : System.IO.FileMode -> System.IO.Stream
Public Function GetStream (mode As FileMode) As Stream

Parameters

mode
FileMode

The I/O mode in which to open the content stream.

Returns

The content stream of the part.

Exceptions

The part has been deleted.

-or-

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

The mode parameter is not a valid FileMode enumeration value.

The mode parameter is not compatible with the package and part stream.

-or-

The stream object returned by the GetStreamCore(FileMode, FileAccess) method of the derived subclass is null.

Remarks

The FileAccess permissions of the returned content stream are the same as the permissions of the parent Package.

Notes to Callers

GetStream(FileMode) internally calls the derived GetStreamCore(FileMode, FileAccess) 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(FileMode) internally calls GetStreamCore(FileMode, FileAccess) of the ZipPackagePart class to open and return the part data stream from a ZIP file.

Applies to

GetStream(FileMode, FileAccess)

Source:
PackagePart.cs
Source:
PackagePart.cs
Source:
PackagePart.cs

Returns the part content stream opened with a specified FileMode and FileAccess.

public:
 System::IO::Stream ^ GetStream(System::IO::FileMode mode, System::IO::FileAccess access);
public System.IO.Stream GetStream (System.IO.FileMode mode, System.IO.FileAccess access);
member this.GetStream : System.IO.FileMode * System.IO.FileAccess -> System.IO.Stream
Public Function GetStream (mode As FileMode, access As FileAccess) As Stream

Parameters

mode
FileMode

The I/O mode in which to open the content stream.

access
FileAccess

The access permissions to use in opening the content stream.

Returns

The content stream for the part.

Exceptions

The part has been deleted.

-or-

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

The mode parameter is not a valid FileMode enumeration value.

-or-

The access parameter is not a valid FileAccess enumeration value.

mode or access is not compatible with the package and part stream.

-or-

The access parameter is specified as Read but the mode parameter requires write access. (FileMode values of Create, CreateNew, Truncate, and Append require Write or ReadWrite access.)

-or-

The stream object returned by the GetStreamCore(FileMode, FileAccess) method of the derived subclass is null.

Notes to Callers

GetStream(FileMode, FileAccess) internally calls the derived GetStreamCore(FileMode, FileAccess) 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(FileMode, FileAccess) internally calls GetStreamCore(FileMode, FileAccess) of the ZipPackagePart class to open and return the part data stream from a ZIP file.

Applies to