This documentation is archived and is not being maintained.

New File Command

Creates a new file and opens it. The file appears under the Miscellaneous Files folder.

File.NewFile [filename] [/t:templatename] [/editor:editorname]

Arguments

filename
Optional. Name for the file. If no name is supplied, a default name is provided. If no template name is listed, a text file is created.

Switches

/t:templatename
Optional. Specifies the type of file to be created.

The /t:templatename argument syntax mirrors the information found in the New File dialog box. You must enter the category name followed by the template name, separating the category name from the template name by a backslash (\) and enclosing the entire string in quotation marks.

For example, to create a new Visual C++ .NET source file, you would enter the following for the /t:templatename argument.

File.NewFile /t:"Visual C++\C++ File (.cpp)"

The example above indicates that the C++ File template is located under the Visual C++ category in the New File dialog box.

/e:editorname
Optional. Name of the editor in which the file will be opened. If the argument is specified but no editor name is supplied, the Open With dialog box appears.

The /e:editorname argument syntax uses the editor names as they appear in the Open With Dialog Box, enclosed in quotation marks.

For example, to open a style sheet in the source code editor, you would enter the following for the /e:editorname argument.

File.NewFile /e:"Source Code (text) Editor"

Example

This example creates a new .htm file, called test1, and opens it in the source code editor.

>File.NewFile test1 /t:"General\HTML Page" /e:"Source Code (text) Editor"

See Also

Visual Studio Commands with Arguments | Command Window | Find/Command Box | Pre-defined Visual Studio Command Aliases

Show: