FileSystem.GetParentPath(String) 方法

定義

回傳所提供路徑的父路徑。

public:
 static System::String ^ GetParentPath(System::String ^ path);
public static string GetParentPath(string path);
static member GetParentPath : string -> string
Public Shared Function GetParentPath (path As String) As String

參數

path
String

需要檢視的道路。

傳回

所提供路徑的父路徑。

例外狀況

路徑沒有父路徑,因為它是根路徑。

pathNothing

路徑超過系統定義的最大長度。

路徑中的檔案或目錄名稱包含冒號(:),或格式無效。

範例

此範例得到 的 C:\Backups\Tmp\Test父路徑。

Dim strPath = My.Computer.FileSystem.GetParentPath("C:\backups\tmp\test")
MsgBox(strPath)

備註

這是一個字串運算;檔案系統不會被檢查。

適用於