Export (0) Print
Expand All
Cut
Run
Expand Minimize

NewFile Method

Visual Studio .NET 2003

Creates a file as though you invoked a New File command in the IDE.

[Visual Basic .NET]
Public Function NewFile( _
   ByVal Item As String, _
   Optional ByVal Name As String = "", _
   Optional ByVal ViewKind As String = "{00000000-0000-0000-0000-000000000000}" _
) As Window
[Visual Basic 6]
Function NewFile( _
   ByVal Item As String, _
   Optional ByVal Name As String = "", _
   Optional ByVal ViewKind As String = "{00000000-0000-0000-0000-000000000000}" _
) As Window
[C++]
HRESULT __stdcall NewFile(
   BSTR Item,
   BSTR Name,
   BSTR ViewKind,
   /* [out, retval] */ Window** retVal
);
[C#]
public Window NewFile(
   string Item,
   string Name,
   string ViewKind
);
[JScript .NET]
public function NewFile(
   Item : String,
   Name : String,
   ViewKind : String
) : Window

Parameters

Item
Required. The virtual path to the item based on the tree nodes from the left pane of the dialog box and the item name from the right pane.
Name
Optional. The name you enter into the Default Name edit box in the dialog box. This name also becomes the suggested Save As name when you save the document.
ViewKind
Optional. A vsViewKind constant specifying the type of view in which to create the file.

Return Value

Returns a Window object.

Remarks

NewFile models the New File dialog box. The contents of this dialog box vary depending on the type of project. To add items to a project using this method, look at the items available for the project in the New File dialog box.

Example

Sub NewFileExample()
   Dim ItemOp As ItemOperations
   ItemOp = DTE.ItemOperations
   ' Adds a new text document to the project.
   ItemOp.NewFile("General\Text File", "Some name", _
     Constants.vsViewKindTextView)
End Sub

See Also

Applies To: ItemOperations Object

Show:
© 2015 Microsoft