VCProject.AddFile - метод
Adds a file to the current project or folder.
Пространство имен: Microsoft.VisualStudio.VCProjectEngine
Сборка: Microsoft.VisualStudio.VCProjectEngine (в Microsoft.VisualStudio.VCProjectEngine.dll)
Синтаксис
'Декларация
Function AddFile ( _
bstrPath As String _
) As Object
'Применение
Dim instance As VCProject
Dim bstrPath As String
Dim returnValue As Object
returnValue = instance.AddFile(bstrPath)
Object AddFile(
string bstrPath
)
Object^ AddFile(
String^ bstrPath
)
function AddFile(
bstrPath : String
) : Object
Параметры
bstrPath
Тип: System.StringRequired. The name of the file to add to the project or folder.
Возвращаемое значение
Тип: System.Object
A VCFile object for the file just added.
Заметки
AddFile behavior on a VCProject object depends on the file's extension. If a file has an extension specified with the Filter property, the file is added to the appropriate folder. Otherwise the file is placed at the end of the Solution Explorer list.
AddFile on a VCFilter object causes the file to be placed in the specified folder, regardless of the file's extension.
Adding a file in this way does not create the file on disk. The caller is responsible for handling that, if necessary.
AddFile on a VCFile object specifies the name of a file to associate with the file.
Примеры
See How to: Compile Example Code for Project Model Extensibility for information about how to compile and run this example.
The following example uses AddFile on a VCProject object in the integrated development environment (IDE):
' add reference to Microsoft.VisualStudio.VCProjectEngine
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine
Public Module Module1
Sub Test()
Dim prj As VCProject
Dim file As VCFile
prj = DTE.Solution.Projects.Item(1).Object
file = prj.AddFile("file.cpp")
MsgBox(file.Name.ToString())
End Sub
End Module
Разрешения
- Полное доверие для непосредственно вызывающего метода. Этот член не может быть использован частично доверенным кодом. Дополнительные сведения см. в разделе Using Libraries from Partially Trusted Code.