共用方式為


Document.Path 屬性

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

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

語法

'宣告
ReadOnly Property Path As String
string Path { get; }
property String^ Path {
    String^ get ();
}
abstract Path : string with get
function get Path () : String

屬性值

類型: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

.NET Framework 安全性

請參閱

參考

Document 介面

EnvDTE 命名空間