Delphi Basics Home  |  Delphi Basics .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
System.IO.Directory.GetParent
 
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.
   C:\Documents and Settings\Thomas\My Documents\Borland Studio Projects
   C:\Documents and Settings\Thomas\My Documents
 
© CodeGear 2006 - 2007. All rights reserved.