Home  |  Delphi .net Home  |  System.IO.Path  |  IsPathRooted Method
IsPathRooted  
Method  
Returns True if the specified Path contains an absolute path
Path Class
System.IO NameSpace
CF1.  Function IsPathRooted ( PathString : String; ) : Boolean; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The IsPathRooted method returns true if the path in the specified PathString is absolute, or false if it is relative to the current directory position.
Microsoft MSDN Links
System.IO
System.IO.Path
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  PathString : String;

begin
  PathString := 'C:\DelphiBasics.txt';

  if System.IO.Path.IsPathRooted(PathString)
  then Console.WriteLine('"{0}" has an absolute path',
                         PathString)
  else Console.WriteLine('"{0}" has a relative path',
                         PathString);

  PathString := 'DelphiBasics.txt';

  if System.IO.Path.IsPathRooted(PathString)
  then Console.WriteLine('"{0}" has an absolute path',
                         PathString)
  else Console.WriteLine('"{0}" has a relative path',
                         PathString);

  Console.Readline;
end.
Show full unit code
  "C:\DelphiBasics.txt" has an absolute path
  "DelphiBasics.txt" has a relative path
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author