Home  |  Delphi .net Home  |  System.IO.Directory  |  GetParent Method
GetParent  
Method  
Gets the parent Directory (folder) name of the specified Path
Directory Class
System.IO NameSpace
NotCF1.  Function GetParent ( PathString : String; ) : DirectoryInfo; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns the parent Directory (folder) to the specified PathString as a DirectoryInfo object.
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
References
DirectoryInfo
Microsoft MSDN Links
System.IO
System.IO.Directory
 
 
Getting the current folder name and its parent folder name
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  Path : String;

begin
  // Get the current folder
  Path := System.IO.Directory.GetCurrentDirectory;
  Console.WriteLine(Path);

  // Get the parent folder
  Console.WriteLine(System.IO.Directory.GetParent(Path));

  Console.Readline;
end.
Show full unit code
  C:\Documents and Settings\Neil\My Documents\Borland Studio Projects
  C:\Documents and Settings\Neil\My Documents
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author