Copy folder, delete folder

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.