Copy Folder
Procedure Tform1.button1click (Sender:tobject);
Var
Ss:tshfileopstruct;
sdir,ddir:string;
Begin
Sdir:=extractfilepath (paramstr (0)) + ' Sou '; SOURCE Directory
Ddir:=extractfilepath (paramstr (0)) + ' Dst ';//Destination Directory
If not directoryexists (Ddir) then Createdir (Ddir); Create the folder if the destination file does not exist
ShowMessage (Sdir);
ShowMessage (Ddir);
If not directoryexists (sdir) then Exit; Exit if no source directory is found
Fillchar (SS, SizeOf (SS), 0);//Initialize SS
Ss. Wnd: = handle;//handle to display status information window
Ss.pfrom: =pchar (sdir+ #0);//source file or directory
Ss.pto: = PChar (Ddir + #0);//target file or directory
Ss.wfunc: = fo_copy;//action to be performed
Ss.fflags: = Fof_silent or fof_noconfirmation;
Flags that control the operation of the file, Fof_noconfirmation does not display a confirmation message during-----operation
SHFileOperation (ss); This is the only way to execute a copy.
End
Delete a folder
Procedure Tform1.button5click (Sender:tobject);
Var
Ss:tshfileopstruct;
sdir,ddir:string;
Begin
Sdir:=extractfilepath (paramstr (0)) + ' Sou ';
Ddir:=extractfilepath (paramstr (0)) + ' Dst2 ';
ShowMessage (Sdir);
ShowMessage (Ddir);
If not directoryexists (Ddir) then Exit;
Fillchar (SS, SizeOf (SS), 0);
Ss. Wnd: = Handle;
Ss.pfrom: =pchar (Ddir + #0);
Ss.pto: = NuLL;
Ss.wfunc: = Fo_delete;
Ss.fflags: = Fof_silent or fof_noconfirmation;
SHFileOperation (ss); This is the only way to do it. Delete
End
Copy folder, delete folder