ItemOperations Interface

Object for performing common file actions.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

[GuidAttribute("D5DBE57B-C074-4E95-B015-ABEEAA391693")]
public interface ItemOperations

The ItemOperations type exposes the following members.

  NameDescription
Public propertyDTEGets the top-level extensibility object.
Public propertyParentGets the immediate parent object of an ItemOperations object.
Public propertyPromptToSaveGets all unsaved files and allows the user to save one or more of them.
Top

  NameDescription
Public methodAddExistingItemAdds an existing item to the current project.
Public methodAddNewItemAdds a new item to the current project.
Public methodIsFileOpenIndicates whether or not the specified saved file is currently open in the specified view.
Public methodNavigateGoes to the given URL.
Public methodNewFileCreates a file as though you invoked a New File command in the integrated development environment (IDE).
Public methodOpenFileOpens a file as though you invoked an Open File command in the integrated development environment (IDE).
Top

You can use the ItemOperations object to programmatically open or add items to your solution and projects. Note that ItemOperations methods act upon only the currently selected item.

This example uses the ItemOperations object to generate a text document listing all available command names.

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft