Copier / déplacer / effacer un répertoire

uses shellapi

function copydir(von,zieldir: String): boolean;
var
fos: TSHFileOpStruct;

begin
ZeroMemory(@fos, SizeOf(fos));
with fos do begin
wFunc := FO_COPY;
fFlags := FOF_FILESONLY;
pFrom := PChar(von+#0);
pTo := PChar(zieldir)
end;
Result:=(0=ShFileOperation(fos));
end;

function movedir(von,zieldir: String): boolean;
var
fos: TSHFileOpStruct;

begin
ZeroMemory(@fos, SizeOf(fos));
with fos do begin
wFunc := FO_MOVE;
fFlags := FOF_FILESONLY;
pFrom := PChar(von+#0);
pTo := PChar(zieldir)
end;
Result:=(0=ShFileOperation(fos));
end;

function deldir(dir: String): boolean;
var
fos: TSHFileOpStruct;

begin
ZeroMemory(@fos, SizeOf(fos));
with fos do begin
wFunc := FO_DELETE;
fFlags := FOF_SILENT or FOF_NOCONFIRMATION;
pFrom := PChar(dir+#0);
end;
Result:=(0=ShFileOperation(fos));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if copydir('d:download','e:')=true then
begin
ShowMessage('Dir copied.');
end;
end;
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour16/11/2001
VisualisationVu 1484 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Fichier
Auteur de l'article
SwissDelphiCenter SwissDelphiCenter
connecté le 02/11/2011
329 articles dans la section
Contacter l'auteur