ForceDirectories (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses a label and a button on a form. When you click the button, all the directories along the specified path that do not exist are created. The results are reported in the caption of the label.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  Dir: string;
begin
  Dir := 'C:\APPS\SALES\LOCAL';
  if SysUtils.ForceDirectories(Dir) then
    Label1.Caption := Dir + ' was created'
end;

Uses