Package.DeletePart(Uri) 方法

定义

使用包中给定的 URI 删除部件。Deletes a part with a given URI from the package.

public:
 void DeletePart(Uri ^ partUri);
public void DeletePart (Uri partUri);
member this.DeletePart : Uri -> unit
Public Sub DeletePart (partUri As Uri)

参数

partUri
Uri

要删除的部件的 URI。The URI of the part to delete.

例外

partUrinullpartUri is null.

partUri 不是有效的 PackagePart URI。partUri is not a valid PackagePart URI.

包未打开(已调用了 Dispose(Boolean)Close())。The package is not open (Dispose(Boolean) or Close() has been called).

包为只读。The package is read-only.

注解

partUri 必须是一个相对 URI,该 URI 包含以正斜杠开头的绝对路径 ( "/" ) 字符。partUri must be a relative URI that consists of an absolute path which starts with a forward slash ("/") character. 绝对路径相对于包根路径,并且根据 RFC 3986 统一资源标识符( (URI) 通用语法规范)来构建。The absolute path is relative to the package root and is formed according to the RFC 3986 Uniform Resource Identifier (URI) Generic Syntax specification. "/page1.xaml" 和 "/images/picture4.jpg" 是有效的部件 Uri 的示例。"/page1.xaml" and "/images/picture4.jpg" are examples of valid part URIs.

如果包中不存在具有指定的的部件,则不会引发异常 partUriNo exception is raised if a part with the specified partUri is not in the package. (你可以使用 PartExists 方法来确定具有指定的部件是否 partUri 在包中。 ) (You can use the PartExists method to determine whether a part with a specified partUri is in the package.)

有关其他信息,请参阅开放打包约定 (OPC) 规范可供下载 https://go.microsoft.com/fwlink/?LinkID=71255For additional information, see the Open Packaging Conventions (OPC) specification available for download at https://go.microsoft.com/fwlink/?LinkID=71255.

继承者说明

DeletePart(Uri) 在内部调用派生类的 DeletePartCore(Uri) 方法,以便根据派生类中实现的物理格式实际删除部件。 DeletePart(Uri) internally calls the derived class's DeletePartCore(Uri) method to actually delete the part based on the physical format implemented in the derived class.

适用于

另请参阅