Home  |  Delphi .net Home  |  System.IO.Directory  |  CreateDirectory Method
CreateDirectory  
Method  
Creates a new Directory or nest of Directories for the specified Path
Directory Class
System.IO NameSpace
CF1.  Procedure CreateDirectory ( PathString : String; ) ; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The hierarchy of directories (folders) in the specified PathString are checked against the actual machine file system. New directories are created so that the full path is now valid.
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System.IO
System.IO.Directory
 
 
Creating a nest of two new directories and then deleting them
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  Path : String;

begin
  Path := 'C:\Dir1\Dir2';

  if System.IO.Directory.Exists(Path)
  then Console.WriteLine('{0} exists', Path)
  else Console.WriteLine('{0} does not exist', Path);

  // Create a nest of 2 new folders
  System.IO.Directory.CreateDirectory(Path);

  if System.IO.Directory.Exists(Path)
  then Console.WriteLine('{0} exists', Path)
  else Console.WriteLine('{0} does not exist', Path);

  // Now delete this nest of folders
  System.IO.Directory.Delete('C:\Dir1', true);

  Console.Readline;
end.
Show full unit code
  C:\Dir1\Dir2 does not exist
  C:\Dir1\Dir2 exists
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author