共用方式為


Document.Path Property

Definition

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

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

Property Value

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

Attributes

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  

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

Applies to