共用方式為


CreateNewFolder 項目 (Visual Studio 範本)

決定是否要檢查建立專案的目標目錄是否不存在。 如果目錄不存在,則可為專案建立全新的目錄。 此設定通常會由 NewProjectRequiresNewFolder(VsTemplate) 登錄旗標 (HKEY_LOCAL_MACHINE/SOFTWARE(/Wow6432Node)/Microsoft/VisualStudio/<version number>/Projects/<project GUID>) 覆寫,所有一般專案類型都會使用此設定來決定是否要在新目錄中建立新專案。

<CreateNewFolder>
    true/false
</CreateNewFolder>

Boolean

屬性和項目

下列章節說明屬性、子項目和父項目。

屬性

無。

子項目

無。

父項目

項目

描述

TemplateData

必要項目。

將範本分類,並定義該範本在 [新增專案] 或 [加入新項目] 對話方塊中顯示的方式。

文字值

需要文字值。

文字必須是 true 或 false,表示是否應該在從範本建立專案時建立新的容器資料夾。

備註

CreateNewFolder 是選擇性項目。 預設值是 true。

僅在基礎專案系統支援時,Visual Studio 才會接受在 CreateNewFolder 項目中指定的值。

範例

下列程式碼範例指定從範本建立專案時,不要建立新資料夾。

<VSTemplate Type="Project" Version="3.0.0"
    xmlns="https://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
        <Name>My template</Name>
        <Description>A basic template</Description>
        <Icon>TemplateIcon.ico</Icon>
        <ProjectType>CSharp</ProjectType>
        <CreateNewFolder>false</CreateNewFolder>
    </TemplateData>
    <TemplateContent>
        <Project File="MyTemplate.csproj">
            <ProjectItem>Form1.cs<ProjectItem>
            <ProjectItem>Form1.Designer.cs</ProjectItem>
            <ProjectItem>Program.cs</ProjectItem>
            <ProjectItem>Properties\AssemblyInfo.cs</ProjectItem>
            <ProjectItem>Properties\Resources.resx</ProjectItem>
            <ProjectItem>Properties\Resources.Designer.cs</ProjectItem>
            <ProjectItem>Properties\Settings.settings</ProjectItem>
            <ProjectItem>Properties\Settings.Designer.cs</ProjectItem>
        </Project>
    </TemplateContent>
</VSTemplate>

請參閱

參考

Visual Studio 範本結構描述參考

概念

在 Visual Studio 中建立專案和項目的範本