Udostępnij za pośrednictwem


Document.Path Property

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

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

Syntax

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

Property Value

Type: System.String
A string representing the path, without file name, for the directory containing the document.

Remarks

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:\.

Examples

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 Security

See Also

Reference

Document Interface

EnvDTE Namespace