如何用Delphi动态创建新文件夹? 谢谢!

解决方案 »

  1.   

    function ForceDirectories(const Dir: string): Boolean;
    DescriptionForceDirectories creates a new directory as specified in Dir, which must be a fully-qualified path name. If the directories given in the path do not yet exist, ForceDirectories attempts to create them.ForceDirectories returns True if it successfully creates all necessary directories, False if it could not create a needed directory.
      

  2.   

    procedure Supper_MkDir(const value:string);
    var i,iSepPosition:integer;
        sTmpDir:array of string;
    begin
         setlength(sTmpDir,255);
         iSepPosition:=1;
         for i:=1 to length(value) do
             if value[i]='\' then
               begin
                 sTmpDir[iSepPosition]:=Copy(value,1,i-1);
                 inc(iSepPosition);
             end;
         sTmpDir[iSepPosition]:= value;
         try
            for i:=1 to iSepPosition do
               if not DirectoryExists(sTmpDir[i]) then
                  MkDir(sTmpDir[i]);
         except
            MessageDlg('建立目录:'+value+'出错!'+#13+#10+''+#13+#10+
                       '请检查目录名是否正确。', mtError, [mbOK], 0);
            raise;
         end;
    end;