Home  |  Delphi .net Home  |  System.IO.Path  |  GetPathRoot Method
GetPathRoot  
Method  
Gets the Root Device or Folder for the specified Path string
Path Class
System.IO NameSpace
CF1.  Function GetPathRoot ( PathString : String; ) : String; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The exact value returned is platform dependant. On the Windows platform, if PathString contains an absolute path, the root is the device, such as C:\, where C is a designated letter for a device such as a hard disk drive.
 
If the path is relative, an empty string is returned.
Microsoft MSDN Links
System.IO
System.IO.Path
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  PathString : String;

begin
  PathString := 'C:\Delphi\DelphiBasics.txt';
  Console.WriteLine('{0} path root : "{1}"',
                    PathString,
                    System.IO.Path.GetPathRoot(PathString));

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