共用方式為


VirtualPathUtility.IsAbsolute(String) 方法

定義

傳回布林值,指出所指定的虛擬路徑是否為絕對,亦即,以常值斜線符號 (/) 開頭。

public:
 static bool IsAbsolute(System::String ^ virtualPath);
public static bool IsAbsolute (string virtualPath);
static member IsAbsolute : string -> bool
Public Shared Function IsAbsolute (virtualPath As String) As Boolean

參數

virtualPath
String

要檢查的虛擬路徑。

傳回

如果 virtualPath 是絕對路徑並且不是 true 或空字串 (""),則為 null,否則為 false

例外狀況

virtualPathnull

範例

下列程式碼範例示範如何使用 IsAbsoluteIsAppRelativeToAppRelative 方法。

StringBuilder sb2 = new StringBuilder();
String pathstring1 = Context.Request.CurrentExecutionFilePath.ToString();
sb2.Append("Current Executing File Path = " + pathstring1.ToString() + "<br />");
sb2.Append("Is Absolute = " + VirtualPathUtility.IsAbsolute(pathstring1).ToString() + "<br />");
sb2.Append("Is AppRelative = " + VirtualPathUtility.IsAppRelative(pathstring1).ToString() + "<br />");
sb2.Append("Make AppRelative = " + VirtualPathUtility.ToAppRelative(pathstring1).ToString() + "<br />");
Response.Write(sb2.ToString());
Dim sb2 As New StringBuilder()
Dim pathstring1 As String = Context.Request.CurrentExecutionFilePath.ToString()
sb2.Append("Current Executing File Path = " & pathstring1.ToString() & "<br />")
sb2.Append("Is Absolute = " & VirtualPathUtility.IsAbsolute(pathstring1).ToString() & "<br />")
sb2.Append("Is AppRelative = " & VirtualPathUtility.IsAppRelative(pathstring1).ToString() & "<br />")
sb2.Append("Make AppRelative = " & VirtualPathUtility.ToAppRelative(pathstring1).ToString() & "<br />")
Response.Write(sb2.ToString())

備註

如果虛擬路徑是以 / (/) 的常值斜線標記開頭,則為絕對路徑。 例如,屬性會 Path 傳回絕對虛擬路徑。

適用於

另請參閱