DocumentBase.Path 屬性

取得文件的磁碟或 Web 路徑。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public ReadOnly Property Path As String
    Get
public string Path { get; }

屬性值

型別:System.String
文件的磁碟或 Web 路徑。

備註

路徑不包含尾端字元,例如 "C:\MSOffice" 或 "http://MyServer"。 使用 PathSeparator 屬性,加入分隔資料夾和磁碟機代號的字元。 使用 Name 屬性傳回檔名但不包含路徑,以及使用 FullName 屬性傳回檔名和路徑。

注意事項注意事項

即使網站位址含有正斜線 (/),且 PathSeparator 是預設為反斜線 (\),您還是可以使用 PathSeparator 屬性建置這些網站位址。

範例

下列程式碼範例會顯示訊息,說明文件的路徑。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentPath()
    MessageBox.Show(Me.Path.ToString())
End Sub 
private void DocumentPath()
{
    MessageBox.Show(this.Path.ToString());
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間