Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Otros temas > Trucos
Register FAQ Members List Calendar Guía de estilo Today's Posts

Los mejores trucos

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07/06/2006
dec's Avatar
dec dec is offline
Moderador
 
Join Date: Dec 2004
Location: Alcobendas, Madrid, España
Posts: 13,142
Poder: 36
dec Tiene un aura espectaculardec Tiene un aura espectacular
Copiar, mover y borrar una carpeta y todo su contenido

Con las siguientes funciones podemos copiar, mover y borar carpetas y todo su contenido:

Código Delphi [-]
uses
  ShlObj, Masks, ShellApi;

function CopiarCarpeta(const carpetaOrigen,
  carpetaDestion: string) : boolean;
var
  FileOp: TSHFileOpStruct;
begin
  FillChar(FileOp, SizeOf(FileOp), #0);
  with FileOp do
  begin
    wFunc := FO_COPY;
    Wnd := GetDesktopWindow;
    pTo := PChar(carpetaOrigen);
    pFrom := PChar(carpetaDestion+#0#0);
    fFlags := FOF_NOCONFIRMATION or
      FOF_SILENT or FOF_ALLOWUNDO;
  end;
  Result := (ShFileOperation(FileOp) = 0);
end;

function MoverCarpeta(const carpetaOrigen,
  carpetaDestion: string) : boolean;
var
  FileOp: TSHFileOpStruct;
begin
  FillChar(FileOp, SizeOf(FileOp), #0);
  with FileOp do
  begin
    wFunc := FO_MOVE;
    Wnd := GetDesktopWindow;
    pTo := PChar(carpetaOrigen);
    pFrom := PChar(carpetaDestion+#0#0);
    fFlags := FOF_NOCONFIRMATION or
      FOF_SILENT or FOF_ALLOWUNDO;
  end;
  Result := (ShFileOperation(FileOp) = 0);
end;

function BorrarCarpeta(const rutaCarpeta: string) : boolean;
var
  FileOp: TSHFileOpStruct;
begin
  FillChar(FileOp, SizeOf(FileOp), #0);
  with FileOp do
  begin
    wFunc := FO_DELETE;
    Wnd := GetDesktopWindow;
    pFrom := PChar(rutaCarpeta+#0#0);
    fFlags := FOF_NOCONFIRMATION or
      FOF_SILENT or FOF_ALLOWUNDO;
  end;
  Result := (ShFileOperation(FileOp) = 0);
end;
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 20:11.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi