Condividi tramite


Proprietà Reference3.Path

Ottiene il percorso al file del riferimento.

Spazio dei nomi:  VSLangProj80
Assembly:  VSLangProj80 (in VSLangProj80.dll)

Sintassi

'Dichiarazione
ReadOnly Property Path As String
    Get
string Path { get; }
property String^ Path {
    String^ get ();
}
abstract Path : string
function get Path () : String

Valore proprietà

Tipo: System.String
Stringa che rappresenta il percorso.

Implementa

Reference2.Path

Note

Se il percorso può essere risolto, Path restituisce il percorso e il nome file del riferimento. Se invece il percorso non può essere risolto, viene restituita una stringa vuota. Per informazioni sulla risoluzione dei riferimenti, vedere Add.

Il percorso non può essere di tipo UNC o URL.

Esempi

Nell'esempio riportato di seguito vengono visualizzati il nome e il percorso del primo riferimento in un progetto aperto di Visual Basic o Visual C#. Per eseguire questo esempio come componente aggiuntivo, vedere Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione.

Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    GetPath(applicationObject)
End Sub
Sub GetPath(ByVal dte As DTE2)
    Dim aProject As Project
    Dim aVSProject As VSProject2
    ' The first project is a Visual Basic or C# project.
    aProject = applicationObject.Solution.Projects.Item(1)
    aVSProject = _
    CType(applicationObject.Solution.Projects.Item(1).Object, _
    VSProject2)
    Dim newRef As Reference3
    newRef = CType(aVSProject.References.Item(1), Reference3)
    MsgBox("The name of the first reference in the project is: " 
    & newRef.Name & vbCr & "its path is: " & newRef.Path)
End Sub
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    GetPath(((DTE2)applicationObject));
}
public void GetPath(DTE2 dte)
{
    // The first project is a Visual Basic or C# project.
    VSProject2 aVSProject =
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    Reference3 aRef = null;
    aRef = ((Reference3)(aVSProject.References.Item(1)));
    MessageBox.Show("The  first reference in the project is: " 
+ aRef.Name +"\n" + "and its path is: " + aRef.Path);
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Reference3 Interfaccia

Overload Path

Spazio dei nomi VSLangProj80