ItemOperations 接口

执行公共文件操作的对象。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
<GuidAttribute("D5DBE57B-C074-4E95-B015-ABEEAA391693")> _
Public Interface ItemOperations
[GuidAttribute("D5DBE57B-C074-4E95-B015-ABEEAA391693")]
public interface ItemOperations
[GuidAttribute(L"D5DBE57B-C074-4E95-B015-ABEEAA391693")]
public interface class ItemOperations
[<GuidAttribute("D5DBE57B-C074-4E95-B015-ABEEAA391693")>]
type ItemOperations =  interface end
public interface ItemOperations

ItemOperations 类型公开以下成员。

属性

  名称 说明
公共属性 DTE 获取顶级扩展性对象。
公共属性 Parent 获取 ItemOperations 对象的直接父对象。
公共属性 PromptToSave 获取所有未保存的文件并允许用户保存其中的一个或多个文件。

页首

方法

  名称 说明
公共方法 AddExistingItem 将现有项添加到当前项目中。
公共方法 AddNewItem 将新项添加到当前项目中。
公共方法 IsFileOpen 指示指定的已保存文件当前是否已在指定视图中打开。
公共方法 Navigate 转到给定的 URL。
公共方法 NewFile 创建一个文件,如同在集成开发环境 (IDE) 中调用“新建文件”命令一样。
公共方法 OpenFile 打开一个文件,如同在集成开发环境 (IDE) 中调用“打开文件”命令一样。

页首

备注

可以使用 ItemOperations 对象以编程方式打开项或将项添加到解决方案和项目中。 请注意,ItemOperations 方法只作用于当前选定的项。

本示例使用 ItemOperations 对象生成列出所有可用命令的名称的文本文档。

示例

Sub ItemOperationsExample()
   Dim Cmds As Commands = DTE.Commands
   Dim Cmd As Command
   Dim Doc As Document
   Dim TxtDoc As TextDocument

   DTE.ItemOperations.NewFile("General\Text File")
   Doc = ActiveDocument
   TxtDoc = Doc.Object("TextDocument")

   For Each Cmd In Cmds
      If (Cmd.Name <> "") Then
         TxtDoc.Selection.Text = Cmd.Name & vbLf
         TxtDoc.Selection.Collapse()
      End If
   Next
End Sub

请参阅

参考

EnvDTE 命名空间