Udostępnij za pośrednictwem


ProjectItem.FileCount Property

Gets the number of files associated with a ProjectItem.

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

Syntax

'Declaration
ReadOnly Property FileCount As Short
short FileCount { get; }
property short FileCount {
    short get ();
}
abstract FileCount : int16
function get FileCount () : short

Property Value

Type: System.Int16
A short integer indicating the number of files associated with a ProjectItem.

Remarks

Most project items consist of only one file, but some can have more than one, as with forms in Visual Basic that are saved as both .frm (text) and .frx (binary) files.

Examples

Sub FileCountExample(ByVal dte As DTE2)

    ' Before running this example, open a project.

    Dim proj As Project = dte.Solution.Projects.Item(1)
    Dim item As ProjectItem
    Dim items As String

    For Each item In proj.ProjectItems
        items &= "    " & item.Name & " (FileCount = " & _
            item.FileCount & ")" & vbCrLf
    Next

    MsgBox(proj.Name & " has the following project items:" & _
        vbCrLf & vbCrLf & items)

End Sub
public void FileCountExample(DTE2 dte)
{
    // Before running this example, open a project.

    Project proj = dte.Solution.Projects.Item(1);
    string items = "";

    foreach (ProjectItem item in proj.ProjectItems)
        items += "    " + item.Name + " (FileCount = " + 
            item.FileCount + ")\n";

    MessageBox.Show(proj.Name + 
        " has the following project items:\n\n" + items);
}

.NET Framework Security

See Also

Reference

ProjectItem Interface

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples