共用方式為


Document.Path 屬性

更新:2007 年 11 月

取得包含文件的目錄路徑,但不含檔名。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

ReadOnly Property Path As String

Dim instance As Document
Dim value As String

value = instance.Path
string Path { get; }
property String^ Path {
    String^ get ();
}
function get Path () : String

屬性值

型別:System.String

字串,代表包含文件的目錄路徑,但不含檔名。

備註

傳回的路徑不包含檔名或副檔名。例如,文件的位置如果是 C:\MsDev\Projects\MyProject\stdafx.cpp,那麼 Path 會傳回 C:\MsDev\Projects\MyProject 字串。除非路徑是某項裝置的根目錄 (例如,C:\),否則不加結尾反斜線。

範例

Sub PathExample()
    Dim doc As Document
    Dim desc As String

    Set doc = DTE.ActiveDocument
    desc = "You are editing a "
    If (doc.ReadOnly) Then
        desc = desc & "read-only"
    Else
        desc = desc & "writable"
    End If
    desc = desc & " document called " & doc.Name & " located at " & doc.Path
    MsgBox desc
End Sub

使用權限

請參閱

參考

Document 介面

Document 成員

EnvDTE 命名空間