TDirectory を利用する - Delphi 2010

Delphi2010では TDirectoryクラスが新しくできました。
以下のコードでは、ディレクトリの存在を確認する例です。
以前は、SysUtils.DirectoryExistsを使いましたが、TDirectory.Existsでも同じことができます。
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IOUtils;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private 宣言 }
  public
    { Public 宣言 }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  label1.Caption := BoolToStr(TDirectory.Exists('c:\windows'), true);
  // DirectoryExists('c:\windows');
end;

end.
著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用
最終更新日: 2014-04-02
作成日: 2009-09-03
iPentec all rights reserverd.