zoukankan      html  css  js  c++  java
  • 一个文件重复生成的小工具[附源码和可执行文件]

    最近,因为项目的需要,我用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.



    可执行文件:文件批量复制工具
  • 相关阅读:
    likely(x)与unlikely(x) __builtin_expect
    c++ ScopeExitGuard
    c++ 11 bind function
    boost shared_ptr weak_ptr
    PL/SQL:使用pragma restrict_references限制包权限
    Nginx的事件处理机制
    读书笔记-HBase in Action-第二部分Advanced concepts-(1)HBase table design
    谈谈工作
    [Java 8] (5) 使用Lambda表达式进行设计
    How to delete a large number of data in SharePoint for List when refreshing data?
  • 原文地址:https://www.cnblogs.com/tester2test/p/1580996.html
Copyright © 2011-2022 走看看