如何在工程目录下创建一个文件夹(判断有就不创建,没有该文件夹就创建),谢谢高手了!

解决方案 »

  1.   

    uses Dialogs;
    begin
      {$I-}
      MkDir(ExtractFileDir(Application.ExeName) + '\Log' );
      if IOResult <> 0 then
        MessageDlg('Cannot create directory', mtWarning, [mbOk], 0, mbOk)
      else
        MessageDlg('New directory created', mtInformation, [mbOk], 0, mbOk);
    end;
      

  2.   

    1.首先判断是否存在该文件夹:
       DirectoryExists(‘文件夹的路径’)
    2.如果不存在则创建:
       CreateDir('新建的文件夹路径和名称')
      

  3.   

    use filectrl;
    ForceDirectories('c:\abcd');
      

  4.   

    try
        if not directoryexists(frootpath+modulname) then
          createdir(FRootPath+modulname);
        if not DirectoryExists(FRootPath+modulname+'\'+pathname) then
        createdir(FRootPath+modulname+'\'+pathname);
        if not directoryexists(FRootPath+modulname+'\'+pathname+'\'+dirname) then
        createdir(FRootPath+modulname+'\'+pathname+'\'+dirname);
        if filepath<>'' then
        if not directoryexists(FRootPath+modulname+'\'+pathname+'\'+dirname+'\'+filepath) then
        createdir(FRootPath+modulname+'\'+pathname+'\'+dirname+'\'+filepath)
        except
        On E:Exception do begin
        abort;
        end;
        end;