美文网首页
2019-06-19 文件内容合并器

2019-06-19 文件内容合并器

作者: netppp | 来源:发表于2019-06-19 10:25 被阅读0次

    unit Unit1;

    interface

    uses

      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

      Dialogs, StdCtrls;

    type

      TForm1 = class(TForm)

        Button1: TButton;

        Memo1: TMemo;

        OpenDialog1: TOpenDialog;

        Memo2: TMemo;

        Button2: TButton;

        Edit1: TEdit;

        Label1: TLabel;

        procedure Button1Click(Sender: TObject);

        procedure Button2Click(Sender: TObject);

      private

        { Private declarations }

      public

        { Public declarations }

      end;

    var

      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);

    var

    x: TextFile;

    m,n:string;

    i:integer;

    begin

      //  if opendialog1.execute  then

      //  filePath:=opendialog1.FileName;

      //  showmessage(filepath.text);

      //  memo1.lines.loadfromfile(filePath);

      //  edit1.text:=filePath;

      // RenameFile('C:\222.txt', 'C:\222.txt');

      // CopyFile(PChar('C:\222.txt'), PChar('C:\22234.txt'), true);

      // MoveFile('C:\ph\update.exe', 'C:\update.exe');

      // DeleteFile('C:\ph\222.txt');

    // AssignFile(x, 'C:\3.txt');

      //Rewrite(x);//创建文件,或者使用ReSet打开文件

      //Writeln(x, edit1.text);

      //CloseFile(x);

          for  i:=0 to memo2.lines.count-1 do

        begin

            n:=memo2.lines[i];

            AssignFile(x,edit1.text+'\'+n);

            reset(x);

            while  not  eof(x) do

            begin

            readln(x,m);

            memo1.Lines.add(m);

            end;

          end;

    end;

    function Searchfile(path: string): TStringList;

    var

      SearchRec: TSearchRec;

      found: integer;

    begin

      Result := TStringList.Create;

      found := FindFirst(path + '\' + '*.*', faAnyFile, SearchRec);

      while found = 0 do

      begin

        if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') and

          (SearchRec.Attr <> faDirectory) then

          Result.Add(SearchRec.Name);

        found := FindNext(SearchRec);

      end;

      FindClose(SearchRec);

    end;

    procedure TForm1.Button2Click(Sender: TObject);

    begin

      Memo2.Lines := Searchfile(edit1.text);

    end;

    end.

    相关文章

      网友评论

          本文标题:2019-06-19 文件内容合并器

          本文链接:https://www.haomeiwen.com/subject/ebrhqctx.html