New File Command
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here
Creates a new file and opens it. The file appears under the Miscellaneous Files folder.
File.NewFile [filename] [/t:templatename] [/editor:editorname]
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.
Optional. Specifies the type of file to be created.
templatename argument syntax mirrors the information found in the New File Dialog Box. Enter the category name followed by a backslash (
\) and the template name, and enclose the entire string in quotation marks.
For example, to create a new Visual C++ source file, you would enter the following for the /t:
/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.
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.
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 file in the source code editor, you would enter the following for the /e:
/e:"Source Code (text) Editor"
This example creates a new Web page "test1.htm" and opens it in the source code editor.
>File.NewFile test1 /t:"General\HTML Page" /e:"Source Code (text) Editor"