1 unit Unit1;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls;
8
9 type
10 TForm1 = class(TForm)
11 Button1: TButton;
12 procedure Button1Click(Sender: TObject);
13 private
14 { Private declarations }
15 public
16 { Public declarations }
17 end;
18
19 var
20 Form1: TForm1;
21
22 implementation
23
24 {$R *.dfm}
25 // If you want to find out of 2 files are equal, then you can use this function:
26
27 function Are2FilesEqual(const fileName1, fileName2: string): boolean;
28 var
29 ms1, ms2: TMemoryStream;
30 begin
31 result := False;
32 ms1 := TMemoryStream.Create;
33 try
34 ms1.LoadFromFile(fileName1);
35 ms2:= TMemoryStream.Create;
36 try
37 ms2.LoadFromFile(fileName2);
38 if ms1.size = ms2.size then
39 result := CompareMem(ms1.Memory, ms2.memory, ms1.size);
40 finally
41 ms2.free;
42 end;
43 finally
44 ms1.free;
45 end
46 end;
47
48 //And you can call it like this:
49 procedure TForm1.Button1Click(Sender: TObject);
50 var
51 bSame:boolean;
52 begin
53 bSame:=Are2FilesEqual('C:\Test1.txt','C:\test2.txt');
54 if bSame then
55 Showmessage('The files are equal')
56 else
57 Showmessage('The files are Not equal');
58 end;
59
60 end.
61
//enjoy ;o)
|