Export (0) Print
Expand All
Expand Minimize

Files Property

Visual Studio .NET 2003

Returns the collection of files on the object.

[Visual Basic .NET]
Public ReadOnly Property Files() As Object
[Visual Basic 6]
Property Get Files() As Object
[C++]
HRESULT __stdcall get_Files(
   /* [out, retval] */ IDispatch** retVal
);
[C#]
public object Files {get;}
[JScript .NET]
public function get Files() : Object

Example

The following sample code uses the Files property on a VCProject object in the development environment:

' add reference to Microsoft.VisualStudio.VCProjectEngine
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine

Public Module Module1
    Sub Test()
        Dim idx As Integer
        Dim prj As VCProject
        Dim mycollection As IVCCollection
        Dim myfile As VCFile

        prj = DTE.Solution.Projects.Item(1).Object
        mycollection = prj.Files
        MsgBox(mycollection.Count)
        For idx = 1 To mycollection.Count
            myfile = mycollection.Item(idx)
            ' myfile.Name has the name of the file
        Next
    End Sub
End Module

The following sample code uses the Files property on a VCFilter object in the development environment:

' add reference to Microsoft.VisualStudio.VCProjectEngine
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine

Public Module Module1
    Sub Test()
        Dim idx, idx2 As Integer
        Dim file As VCFile
        Dim filter As VCFilter
        Dim col, col2 As IVCCollection
        Dim prj As VCProject
        prj = DTE.Solution.Projects.Item(1).Object
        col = prj.Filters
        For idx = 1 To col.Count
            filter = col.Item(idx)
            ' filter.Name has name of the folder
            col2 = filter.Files
            For idx2 = 1 To col2.Count
                file = col2.Item(idx2)
                ' file.Name has name of file
            Next
        Next
    End Sub
End Module

See Samples for Project Model Extensibility for information on how to compile and run this sample.

See Also

Applies To: VCFilter Object | VCProject Object

Show:
© 2014 Microsoft