够简单吧,最好有例子

解决方案 »

  1.   

    {    if not DirectoryExists('c:\temp') then
        if not CreateDir('C:\temp') then
        raise Exception.Create('Cannot create c:\temp');  //创建目录if FileExists(FileName) then
      if MessageDlg('Do you really want to delete ' + ExtractFileName(FileName) + '?'), mtConfirmation, [mbYes, mbNo], 0, mbNo) = IDYes then 
        DeleteFile(FileName);  //删除文件  }//copyfileA('c:\gz\gz.txt','a:\gz.txt',false);  //复制文件//ForceDirectories(extractfilepath(application.ExeName)+'bbb');
      

  2.   

    楼上说的很详细了,我再贴个删除的:
    procedure TForm1.Button1Click(Sender: TObject);
    Var
      T:TSHFileOpStruct;
      P:String;
    begin
      P:='d:\address';//这里改成你要删除的任意目录名
      With T do
      Begin
        Wnd:=0;
        wFunc:=FO_DELETE;
        pFrom:=Pchar(P);
        pTo:=nil;
        fFlags:=FOF_ALLOWUNDO+FOF_NOCONFIRMATION+FOF_NOERRORUI;//标志表明允许恢复,无须确认并不显示出错信息
        hNameMappings:=nil;
        lpszProgressTitle:='正在删除文件夹';
        fAnyOperationsAborted:=False;
      End;
      SHFileOperation(T);
    end;
    ...
    //删除到回收站
    procedure TForm1.Button1Click(Sender: TObject);
    var
      fo: TSHFileOpStruct;
      fname: string;
    begin
      fname := edit1.Text;
      with fo do
      begin
        Wnd := self.Handle;
        wFunc := FO_DELETE;
        pFrom := Pchar(fname + #0#0);
        pTo := nil;
        fFlags := FOF_ALLOWUNDO
      end;  SHFileOperation(fo);
    end;
      

  3.   

    uses FileCtrl;
    创建目录
    function ForceDirectories(const Dir: string): Boolean;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      ifnot DirectoryExists('c:\temp') then
        ifnot CreateDir('C:\temp') then
        raise Exception.Create('Cannot create c:\temp');
    end;
    创建文件
    procedure TForm1.Button1Click(Sender: TObject);
    var
      BackupName: string;
      FileHandle: Integer;
      StringLen: Integer;
      X: Integer;
      Y: Integer;
    begin
      if SaveDialog1.Execute then
      begin
        if FileExists(SaveDialog1.FileName) then
        begin
          BackupName := ExtractFileName(SaveDialog1.FileName);
          BackupName := ChangeFileExt(BackupName, '.BAK');
          if not RenameFile(SaveDialog1.FileName, BackupName) then        raise Exception.Create('Unable to create backup file.');
        end;
        FileHandle := FileCreate(SaveDialog1.FileName);
        { Write out the number of rows and columns in the grid. }
        FileWrite(FileHandle, 
          StringGrid1.ColCount, SizeOf(StringGrid1.ColCount));
        FileWrite(FileHandle, 
          StringGrid1.RowCount, SizeOf(StringGrid1.RowCount));
        for X := 0 to StringGrid1.ColCount – 1 do
        begin      for Y := 0 to StringGrid1.RowCount – 1 do
          begin
            { Write out the length of each string, followed by the string itself. }
            StringLen := Length(StringGrid1.Cells[X,Y]);
            FileWrite(FileHandle, StringLen, SizeOf(StringLen));
            FileWrite(FileHandle,
              StringGrid1.Cells[X,Y], Length(StringGrid1.Cells[X,Y]);
          end;
        end;
        FileClose(FileHandle);
      end;end;删除目录
    function RemoveDir(const Dir: string): Boolean;删除文件
    function DeleteFile(const FileName: string): Boolean;都是在DELPHI帮忙的
      

  4.   

    删除目录
    function RemoveDir(const Dir: string): Boolean;删除文件
    function DeleteFile(const FileName: string): Boolean;
      

  5.   

    创建文件只能是一个层次的,我刚写了个支持多级目录创建的子程序:  function CreateNewDirectory(NewDirectory: String): Boolean;
      Type
        SECURITY_ATTRIBUTES = Record
           nLength: LongInt;
           lpSecurityDescriptor: LongInt;
           bInheritHandle: Boolean;
        End;
      var
        sDirTest: String;
        SecAttrib: SECURITY_ATTRIBUTES;
        sPath: PChar;
        iCount: Integer;
        sTempDir: PChar;
        iFlag: Integer;
      begin
        iFlag := 0;
        sTempDir := '';
        sPath := PChar(NewDirectory); //等于子程序取得的目录
        if (Copy(sPath, StrLen(sPath), 1) <> '\') then //判断,如果最右边的字符不为"\",则加上
        begin
          sPath := PChar(sPath + '\');
        end;
        while Pos('\', sPath) > 0 do
        begin
          iCount := Pos('\', sPath);
          sTempDir := PChar(sTempDir + Copy(sPath, 1, iCount));
          sPath := sPath + iCount;
          if Not DirectoryExists(sTempDir) then
          begin
            SecAttrib.lpSecurityDescriptor := $00;
            SecAttrib.bInheritHandle := false;
            SecAttrib.nLength := SizeOf(SecAttrib);
            Result := CreateDirectory(sTempDir, @SecAttrib); //建立目录
          end;
        end;
      end;支持多级目录CreateNewDirectory('e:\a\b\c\d\e\f');
      

  6.   

    cooling(cooling) :
    ForceDirectories这个函数就能实现你写的功能