Package.GetParts 方法

定義

傳回套件中所有組件的集合。

C#
public System.IO.Packaging.PackagePartCollection GetParts();

傳回

包含在套件中的所有 PackagePart 項目的集合。

例外狀況

套件沒有開啟 (已呼叫 Dispose(Boolean)Close())。

封裝是唯寫的。

備註

GetParts 會傳回封裝中包含的所有元件集合,包括 PackageRelationship 元件。

GetParts 永遠不會傳回 null;不過,如果封裝不包含任何元件,則傳回的集合將包含零個專案。

根據預設, ZipPackage 會提供及使用抽象 Package 基類的衍生實作。 在默認作業中ZipPackageGetParts呼叫 GetPartsCore 類別的方法,以從 ZIP 檔案傳回元件。

如需套件和套件元件的詳細資訊,請參閱 open Packaging Conventions (OPC) 規格的 1.1 節,可在 下載。https://www.ecma-international.org/publications-and-standards/standards/ecma-376/

給繼承者的注意事項

GetParts() 內部呼叫衍生類別方法,根據衍生類別 GetPartsCore() 中實作的實體格式,實際排清元件。

適用於

產品 版本
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另請參閱