Home  |  Delphi .net Home  |  System.IO.Path  |  GetDirectoryName Method
GetDirectoryName  
Method  
Gets the Directory (folder) name part of the specified Path string
Path Class
System.IO NameSpace
CF1.  Function GetDirectoryName ( PathString : String; ) : String; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The PathString string is returned with the file name and extension, if present, removed. The directory is the name of a directory or folder that may contain files.
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\Testing\DelphiBasics.txt';

  Console.WriteLine('"{0}" has directory name "{1}"',
                    PathString,
                    System.IO.Path.GetDirectoryName(PathString));

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