DELPHI 判断文件夹是否存在,递归创建文件夹

procedure TForm1.btn1Click(Sender: TObject);
var
  path:string;
begin
  path := edt1.Text;
  if path <> '' then
    begin
      path := StringReplace(path, '/', '\', [rfReplaceAll]);
      if not DirectoryExists(path) then  //查找文件夹是否存在
        begin
        //建立文件夹(ForceDirectories可建立多级目录,创建单级目录用:CreateDirectory)
        ForceDirectories(path);
        end
      else
        begin
        showmessage('目录已经存在');
        end;
    end
  else
    begin
      ShowMessage('请填写目录');
    end;
end;
posted @ 2013-11-27 10:00  內個誰²º¹³  阅读(564)  评论(0编辑  收藏  举报