Package.PartExists Method

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

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

public virtual bool PartExists (
	Uri partUri
public boolean PartExists (
	Uri partUri
public function PartExists (
	partUri : Uri
) : boolean
You cannot use methods in XAML.



The Uri of the part to check for.

Return Value

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

Exception typeCondition


partUri is a null reference (Nothing in Visual Basic).


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


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


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

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

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