Document::Path Property

 

Gets the path, without file name, for the directory containing the document.

Namespace:   EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

property String^ Path {
	String^ get();
}

Property Value

Type: System::String^

A string representing the path, without file name, for the directory containing the document.

The returned path does not include the file name or extension. For example, if the document location is C:\MsDev\Projects\MyProject\stdafx.cpp, then Path returns the string, C:\MsDev\Projects\MyProject. There is no ending backslash unless the path is the root of a device, such as 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
Return to top
Show: