请问我要创建文件、夹删除文件夹、把文件夹改名,用Delphi怎么现实。我找的方法只在win3.1中有用,但我想要在win32中能用的函数

解决方案 »

  1.   

    MkDir,CreateDir,ForceDirectories,RmDir,RemoveDir,CreateFile,RenameFile,DeleteFile
      

  2.   

    procedure makedir(modulname,pathname,dirname,filepath:string);
    begin
    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;
    删:RemoveDir
      

  3.   

    //我也来up
    //清空一个目录
    function EmptyDirectory(TheDirectory :String ; Recursive : Boolean):Boolean;stdcall;export;
    var
      SearchRec : TSearchRec;
      Res : Integer;
    begin
      Result := False;
      TheDirectory := Trim(TheDirectory);
      if copy(TheDirectory,Length(TheDirectory),1)<>'\' then
        TheDirectory :=TheDirectory+'\';
        Res := FindFirst(TheDirectory + '*.*', faAnyFile, SearchRec);
        try
          while Res = 0 do
          begin
            if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
            begin
            if ((SearchRec.Attr and faDirectory) > 0) and Recursive then
              begin
              EmptyDirectory(TheDirectory + SearchRec.Name, True);
              RemoveDirectory(PChar(TheDirectory + SearchRec.Name));
              end
            else
            begin
            DeleteFile(PChar(TheDirectory + SearchRec.Name))
            end;
          end;
          Res := FindNext(SearchRec);
        end;
        Result := True;
        finally
        FindClose(SearchRec);
      end;
    end;