Delphi 文件夹操作

uses
  ShellApi

//建立文件夹
procedure TfrmMain.cxButton1Click(Sender: TObject);
begin
  CreateDirectory(PChar(ExtractFilePath(ParamStr(0))+ 'Microblue'),nil);
end;

//删除文件夹,放到回收站
procedure TfrmMain.cxButton2Click(Sender: TObject);
var
  T: TSHFileOpStruct;
  P: String;
begin
  P := ExtractFilePath(ParamStr(0)) + 'Microblue';
  with T do
  begin
    Wnd := 0;
    wFunc := FO_DELETE;
    pFrom := PChar(P);
    pTo := nil;
    fFlags := FOF_ALLOWUNDO + FOF_NOERRORUI;
    hNameMappings := nil;
    lpszProgressTitle := '正在删除文件夹';
    fAnyOperationsAborted := False;
  end;
  if SHFileOperation(T) = 0 then
  begin
    ShowMessage('删除成功!');
  end
  else
  begin
    ShowMessage('删除失败!');
  end;  
end;

//直接删除文件夹
procedure TfrmMain.cxButton3Click(Sender: TObject);
begin
  RemoveDirectory (Pchar(ExtractFilePath(ParamStr(0))+ 'Microblue'));
end;


你可能感兴趣的:(delete,Delphi)