![]() |
AW: File compare
Zitat:
|
AW: File compare
Kann ich auch irgendwie herausfinden, was genau sich geändert hat? zB die betroffene Zeile?
LG |
AW: File compare
Geht es nur um Textdateien? Ansonsten gibt es ja keine Zeilen.
|
AW: File compare
^jap ich vergleiche praktisch 2 textdateien!
LG |
AW: File compare
Die kannst Du doch einfach zeilenweise einlesen und vergleichen.
|
AW: File compare
Nur mal noch bezüglich Gleichheitsprüfung:
Vorausgesetzt, die Texdateien sind nicht zu groß, könnte man sie einfach in 2 TStringList laden und auf
Delphi-Quellcode:
prüfen. Zumindest wäre das ein recht unkomplizierter Weg.
SL1.Text = SL2.Text
|
AW: File compare
Damit bekommst aber keine Zeilennummer bei evtl. Unterschieden ;)
|
AW: File compare
so in etwa?
ich mein sieht grauslich aus aber wäre das prinzip richtig?
Delphi-Quellcode:
i := 0;
i2 := 0; countsum := getlinecount('C:\myfile.txt'); sl := TStringlist.Create; sl2 := TStringlist.Create; sl.loadfromfile('C:\myfile.txt'); sl2.loadfromfile('C:\my2ndFile.txt'); while i < countsum do begin i := i + 1; i2 := i2 + 1; if sl[i] = sl[i2] then writeln('Kein Unterschied'); end; ... |
AW: File compare
Ungetestet:
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; end; inc(i); end; finally s2.Free; end; finally s1.Free; end; end; end; |
AW: File compare
Delphi-Quellcode:
Result := FileExists(First) and FileExists(Second);
if Result then begin s1 := TStringlist.Create; try s2 := TStringlist.Create; try s1.LoadFromFile(First); s2.LoadFromFile(Second); Result := s1.Count = s2.Count if Result then begin i := 0; while (i < s1.Count) and (i < s2.Count) do begin Result := s1[i] = s2[i]; if not Result then begin DiffLine := i; Break; end; inc(i); end; end else DiffLine := Min(s1.Count, s2.Count); finally s2.Free; end; finally s1.Free; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:28 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz