Path(DirListBox)


Pathプロパティは DirListBoxの現在のパスを返します。Delphi では TDirectoryListBoxの 「Directory」プロパティを使用します。VBと同じくルートの場合以外は最後に¥マークがつかないので注意してください。また, Delphiの DirecotryListBoxコンポーネントには FileListプロパティと言うものがあり, ここに FileListBoxを指定すればいちいちディレクトリが変更されたらファイルリストボックスの内容も変更する と言う処理を記述しなくても自動で反映されるようになります。

■ Directoryの使用例
  procedure TForm1.Button1Click(Sender: TObject);
  var
    strPath : string;
  begin
    {選ばれているディレクトリ¥つきで表示}
    strPath   :=    DirectoryListBox1.Directory;
    if  (Copy(strPath,Length(strPath),1) <> '\' ) then begin
      strPath :=    strPath + '\';
    end;
    ShowMessage (strPath);
  end;