Path.IsPathRooted メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim path As String Dim returnValue As Boolean returnValue = Path.IsPathRooted(path)
戻り値
path に絶対パスが含まれている場合は true。それ以外の場合は false。


このメソッドは、パス名またはファイル名が存在することを検査しません。
IsPathRooted は、"\\MyDir\\MyFile.txt" や "C:\\MyDir" などの path 文字列に対しては true を返します。"MyDir" などの path 文字列に対しては、false を返します。
このメソッドの使用例については、以下の「使用例」を参照してください。その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。

IsPathRooted プロパティの使用方法を次のコード例に示します。
Dim fileName As String = "C:\mydir\myfile.ext" Dim UncPath As String = "\\myPc\mydir\myfile" Dim relativePath As String = "mydir\sudir\" Dim result As Boolean result = Path.IsPathRooted(fileName) Console.WriteLine("IsPathRooted('{0}') returns {1}", fileName, result) result = Path.IsPathRooted(UncPath) Console.WriteLine("IsPathRooted('{0}') returns {1}", UncPath, result) result = Path.IsPathRooted(relativePath) Console.WriteLine("IsPathRooted('{0}') returns {1}", relativePath, result) ' This code produces output similar to the following: ' ' IsPathRooted('C:\mydir\myfile.ext') returns True ' IsPathRooted('\\myPc\mydir\myfile') returns True ' IsPathRooted('mydir\sudir\') returns False
string fileName = @"C:\mydir\myfile.ext"; string UncPath = @"\\myPc\mydir\myfile"; string relativePath = @"mydir\sudir\"; bool result; result = Path.IsPathRooted(fileName); Console.WriteLine("IsPathRooted('{0}') returns {1}", fileName, result); result = Path.IsPathRooted(UncPath); Console.WriteLine("IsPathRooted('{0}') returns {1}", UncPath, result); result = Path.IsPathRooted(relativePath); Console.WriteLine("IsPathRooted('{0}') returns {1}", relativePath, result); // This code produces output similar to the following: // // IsPathRooted('C:\mydir\myfile.ext') returns True // IsPathRooted('\\myPc\mydir\myfile') returns True // IsPathRooted('mydir\sudir\') returns False
String^ fileName = "C:\\mydir\\myfile.ext"; String^ UncPath = "\\\\myPc\\mydir\\myfile"; String^ relativePath = "mydir\\sudir\\"; bool result; result = Path::IsPathRooted( fileName ); Console::WriteLine( "IsPathRooted('{0}') returns {1}", fileName, result.ToString() ); result = Path::IsPathRooted( UncPath ); Console::WriteLine( "IsPathRooted('{0}') returns {1}", UncPath, result.ToString() ); result = Path::IsPathRooted( relativePath ); Console::WriteLine( "IsPathRooted('{0}') returns {1}", relativePath, result.ToString() );
String fileName = "C:\\mydir\\myfile.ext"; String UncPath = "\\\\myPc\\mydir\\myfile"; String relativePath = "mydir\\sudir\\"; boolean result; result = Path.IsPathRooted(fileName); Console.WriteLine("IsPathRooted('{0}') returns {1}", fileName, System.Convert.ToString(result)); result = Path.IsPathRooted(UncPath); Console.WriteLine("IsPathRooted('{0}') returns {1}", UncPath, System.Convert.ToString (result)); result = Path.IsPathRooted(relativePath); Console.WriteLine("IsPathRooted('{0}') returns {1}", relativePath, System.Convert.ToString (result));
var fileName : String = "C:\\mydir\\myfile.ext"; var UncPath : String = "\\\\myPc\\mydir\\myfile"; var relativePath : String = "mydir\\sudir\\"; var result : boolean; result = Path.IsPathRooted(fileName); Console.WriteLine("IsPathRooted('{0}') returns {1}", fileName, result); result = Path.IsPathRooted(UncPath); Console.WriteLine("IsPathRooted('{0}') returns {1}", UncPath, result); result = Path.IsPathRooted(relativePath); Console.WriteLine("IsPathRooted('{0}') returns {1}", relativePath, result);

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Path.IsPathRooted メソッドのページへのリンク