Package.PartExists(Uri) Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Indicates whether a part with a given URI is in the package.

C#
public virtual bool PartExists(Uri partUri);

Parameters

partUri
Uri

The Uri of the part to check for.

Returns

true if a part with the specified partUri is in the package; otherwise, false.

Exceptions

partUri is null.

partUri is not a valid PackagePart uniform resource identifier (URI).

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

The package is write-only (information cannot be read).

Remarks

The partUri should begin with a forward-slash character "/" and be absolute from the root of the package.

For additional information, see the Open Packaging Conventions (OPC) specification available for download at https://www.ecma-international.org/publications-and-standards/standards/ecma-376/.

Applies to

Product Versions
.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

See also