批量文件复制

运行 环境 delphi7

原代码

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, FileCtrl;

type
  TForm1 = class(TForm)
    Button1: TButton;
    FileListBox1: TFileListBox;
    DriveComboBox1: TDriveComboBox;
    DirectoryListBox1: TDirectoryListBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure DirectoryListBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
    filelistbox1.Mask:=Edit1.Text;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i:integer;
  j:integer;
  s:string;

begin
  try
    s:=filelistbox1.Directory;
    for i:=0 to filelistbox1.Count-1 do
    begin
      if filelistbox1.Selected[i] then
        copyfile(pchar(s+'\'+filelistbox1.Items.Strings[i]),pchar(edit2.Text+'\'+filelistbox1.Items.Strings[i]),False);
    end;
    application.MessageBox('yes','t',0);
  except
    application.MessageBox('not','t',0);
end;
end;

procedure TForm1.DirectoryListBox1Change(Sender: TObject);
begin
filelistbox1.FileName:=DirectoryListBox1.Directory ;

end;

end.


界面设计:

原文地址:https://www.cnblogs.com/javawebsoa/p/3057439.html