Reference3.Path 属性

定义

获取引用文件的路径。

public:
 property System::String ^ Path { System::String ^ get(); };
public:
 property Platform::String ^ Path { Platform::String ^ get(); };
[System.Runtime.InteropServices.DispId(8)]
public string Path { [System.Runtime.InteropServices.DispId(8)] get; }
[<System.Runtime.InteropServices.DispId(8)>]
[<get: System.Runtime.InteropServices.DispId(8)>]
member this.Path : string
Public ReadOnly Property Path As String

属性值

String

一个表示该路径的字符串。

实现

属性

示例

此示例在打开的或项目中显示第一个引用的名称和 Visual Basic 路径 Visual C# 。 若要将此示例作为外接程序运行,请参阅 如何:编译和运行自动化对象模型代码示例

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);  
}  

注解

Path 如果可以解析引用,则返回该引用的路径和文件名。 如果无法解析路径,则返回一个空字符串。 有关解析引用的信息,请参阅 Add

路径不能为 UNC 或 URL。

适用于