Solution2.FindProjectItem(String) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Sucht ein Element in einem Projekt.
public:
EnvDTE::ProjectItem ^ FindProjectItem(System::String ^ FileName);
public:
EnvDTE::ProjectItem ^ FindProjectItem(Platform::String ^ FileName);
EnvDTE::ProjectItem FindProjectItem(std::wstring const & FileName);
[System.Runtime.InteropServices.DispId(42)]
public EnvDTE.ProjectItem FindProjectItem (string FileName);
[<System.Runtime.InteropServices.DispId(42)>]
abstract member FindProjectItem : string -> EnvDTE.ProjectItem
Public Function FindProjectItem (FileName As String) As ProjectItem
Parameter
- FileName
- String
Erforderlich. Der Name des Projektelements.
Gibt zurück
Ein ProjectItem-Objekt.
Implementiert
- Attribute
Beispiele
Sub SolnFindProjectItemExample(ByVal dte As DTE2)
' Finds a project item in a solution.
' Make sure you have a solution open in Visual Studio before running this example.
Try
Dim soln As Solution2 = _
CType(_applicationObject.Solution, Solution2)
MsgBox("Finding a project item in the solution ")
' Find the specified project.
Dim proj As ProjectItem
proj = soln.FindProjectItem _(soln.Projects.Item(1).ProjectItems.Item(1).Name.ToString())
MsgBox(proj.Name.ToString())
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
//you will need to add this to your project references
using System.Windows.Forms;
public void CreateExample(DTE2 dte)
{
// Finds a project item in a solution.
// Open a solution in Visual Studio before running this example.
try
{
Solution2 soln = (Solution2)_applicationObject.Solution;
MessageBox.Show("Finding a project item in the solution.");
ProjectItem proj;
proj =
soln.FindProjectItem
(soln.Projects.Item(1).ProjectItems.Item(1).Name.ToString());
MessageBox.Show("The project item found is: "
+ proj.Name.ToString());
}
catch (SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
Hinweise
FindProjectItem führt einen ItemOperations.OpenFile Suchtyp für den angegebenen Dateinamen aus. Das erste Projekt, das gefunden wurde, damit das Element sein- ProjectItem Objekt für den Namen zurückgibt. Wenn die Datei in der Projekt Mappe nicht gefunden wird, null wird zurückgegeben.