Thema: File compare

Einzelnen Beitrag anzeigen

value is NULL

Registriert seit: 10. Sep 2010
249 Beiträge
 
#23

AW: File compare

  Alt 24. Mai 2011, 15:09
hm habe folgende function:

Delphi-Quellcode:
function FilesEqual(const First, Second: TFilename; out DiffLine: integer): Boolean;
var
  s1, s2: TStringlist;
  i: integer;
begin
  Result := FileExists(First) and FileExists(Second);
  if Result then
    begin
      s1 := TStringlist.Create;
      try
        s1.LoadFromFile(First);
        s2 := TStringlist.Create;
        try
          s2.LoadFromFile(Second);
          i := 0;
              while (i < s1.Count) and (i < s2.Count) do
              begin
                Result := s1[i] = s2[i];
                if not Result then
                  begin
                    DiffLine := i;
                    i := s1.Count;
                    s3.Add(s1[i]);
                  end;
                  inc(i);
                end;
        finally
          s2.Free;
        end;
      finally
        s1.Free;
      end;
    end;
end;
und rufe das auf:

Delphi-Quellcode:
    test_functions.FilesEqual('C:\software.txt','C:\software2.txt',i);
    i2 := 0;
    for i2 := 0 to vlxsysstate_functions.s3.Count -1 do
        Writeln(s3[i2]);
    test_functions.s3.Free;
bekomme aber permanent folgendes:

EStringListError: Listenindex ³berschreitet das Maximum (166)

was ist da falsch?
  Mit Zitat antworten Zitat