Share via


VCFilter.CanAddFile(String) Method

Definition

Returns true if the specified file can be added to the current filter.

public:
 bool CanAddFile(System::String ^ bstrFile);
public:
 bool CanAddFile(Platform::String ^ bstrFile);
bool CanAddFile(std::wstring const & bstrFile);
[System.Runtime.InteropServices.DispId(2349)]
public bool CanAddFile (string bstrFile);
[<System.Runtime.InteropServices.DispId(2349)>]
abstract member CanAddFile : string -> bool
Public Function CanAddFile (bstrFile As String) As Boolean

Parameters

bstrFile
String

Required. The new file to be added. The full path must be unique in the project and valid. If you pass a relative path here, it is assumed to be relative to the project directory.

Returns

true if the file can be added; otherwise, false.

Attributes

Examples

The following example uses CanAddFile in the integrated development environment (IDE):

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

Public Module Module1  
    Sub Test()  
        Dim mycollection As IVCCollection  
        Dim filter As VCFilter  
        Dim prj As VCProject  
        Dim ret As Boolean  
        prj = DTE.Solution.Projects.Item(1).Object  
        mycollection = prj.Filters  
        'mycollection.Count has count of files  
        filter = mycollection.Item(1)  
        ret = filter.CanAddFile("somefile.cpp")  
        MsgBox(ret)  
    End Sub  
End Module  

Remarks

See How to: Compile Example Code for Project Model Extensibility for information about how to compile and run this example.

Applies to