Package::GetPart Method
Returns the part with a given URI.
Assembly: WindowsBase (in WindowsBase.dll)
Parameters
- partUri
- Type: System::Uri
The uniform resource identifier (URI) of the part to return.
| Exception | Condition |
|---|---|
| ArgumentNullException | partUri is nullptr. |
| ArgumentException | partUri is not a valid PackagePart uniform resource identifier (URI). |
| InvalidOperationException | A part with the specified partUri is not in the package. |
| ObjectDisposedException | |
| IOException | The package is write-only. |
An InvalidOperationException is thrown if a part with the specified partUri does not exist.
The PartExists method can be used to determine whether partUri references an existing part.
By default, a ZipPackage derived implementation of the abstract Package base class is provided and used. In the default operation, GetPart internally calls GetPartCore of the ZipPackage class to return a requested part from a ZIP file.
For additional information, see the Open Packaging Conventions (OPC) specification available for download at http://go.microsoft.com/fwlink/?LinkID=71255.
Notes to InheritorsGetPart internally calls the derived class GetPartCore method to actually flush the part based on the physical format implemented in the derived class.
The following example shows how to locate, retrieve, and read parts that are contained in a package. For the complete sample, see Reading a Package Sample.
Windows 7, Windows Vista SP1 or later, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.