• 一个文件重复生成的小工具[附源码和可执行文件]


    最近,因为项目的需要,我用Delphi开发了一个小的程序。程序的功能就是选择一个文件,而后可以指定复制多少个相同的文件,用这些复制的文件做并发上传文件用。下面附源码和可执行文件。

    源码如下:


    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, SUIButton, Buttons, StdCtrls, ExtCtrls, SUIForm, ComCtrls;

    type
      TForm1 = class(TForm)
        suiForm1: TsuiForm;
        lbl1: TLabel;
        edt1: TEdit;
        btn1: TSpeedButton;
        lbl2: TLabel;
        edt2: TEdit;
        btn2: TsuiButton;
        btn3: TsuiButton;
        dlgOpen1: TOpenDialog;
        pb1: TProgressBar;
        procedure btn2Click(Sender: TObject);
        procedure btn1Click(Sender: TObject);
        procedure btn3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.btn2Click(Sender: TObject);
    var
      i:integer;
      str:string;
    begin

      if Trim(edt1.Text)='' then begin
        Application.MessageBox('请选择要复制的源文件!', '提示', MB_OK +
          MB_ICONINFORMATION);
        btn1.Click();
        Exit;
      end;

      try
        if StrToInt(edt2.Text)<=0 then begin
                  edt2.Clear;
            edt2.SetFocus;
            Exit;
        end;

        except
          Application.MessageBox('请输入合法数值!', '提示', MB_OK +
            MB_ICONINFORMATION);
            edt2.Clear;
            edt2.SetFocus;
          exit;
          end;
          pb1.Max:=StrToInt(edt2.Text);

      if not DirectoryExists('c:\测试数据') then
        ForceDirectories('c:\测试数据');

      for i:=1 to StrToInt(edt2.Text) do
      begin
        try
        str:='c:\测试数据\'+Copy(ExtractFileName(edt1.Text),1,Length(ExtractFileName(edt1.Text))-4)+inttostr(i)+Copy(ExtractFileName(edt1.Text),Length(ExtractFileName(edt1.Text))-4+1,4);
        CopyFile(PChar(edt1.text),PChar(str),False);
        pb1.Position:=i;
        except
          end;
        end;
      Application.MessageBox('文件生成完毕,数据存放于"c:\测试数据"目录!', '提示', MB_OK +
            MB_ICONINFORMATION);
    end;

    procedure TForm1.btn1Click(Sender: TObject);
    begin
         dlgOpen1.Execute;
         edt1.Text:=dlgOpen1.FileName;
    end;

    procedure TForm1.btn3Click(Sender: TObject);
    begin
         Application.Terminate;
    end;

    end.



    可执行文件:文件批量复制工具
  • 相关阅读:
    SMI/慧荣/SM32**主控量产通用教程,PNY U盘量产!
    显示隐藏文件的批处理!
    office2003与office2007/2010文件关联问题!
    WDS功能及中继与桥接模式的区别.
    利用WinRar命令行定时备份Sql2005数据库!
    windows 7 关机的误区及睡眠和休眠的作用。
    ajax helloworld jsp ajax入门,后台使用jsp
    jquery width height innerWidth innerHeight
    d3.js GeoJSON 显示陕西省地图 projection
    jquery 向html添加元素append prepend before after
  • 原文地址:https://www.cnblogs.com/tester2test/p/1580996.html
Copyright © 2020-2023  润新知