Sorry Buddies, hab' mich vertippt.
Ich meinte, ob es möglich ist, herauszufinden, ob eine Datei Textformat hat.
Ungetestet:
Delphi-Quellcode:
function IsAsciiFormat(const FileName: string): boolean;
const
Size = 2048;
var
I: integer;
F: File;
TotSize, IncSize, ReadSize: integer;
C: array [0..Size] of Byte;
begin
Result:= false;
AssignFile(F, FileName);
try
Reset(F, 1);
try
TotSize:= FileSize(F);
IncSize:= 0;
Result:= true;
while Result and (IncSize < TotSize) do
begin
ReadSize:= Size;
if IncSize + ReadSize > TotSize then ReadSize:= TotSize - IncSize;
IncSize:= IncSize + ReadSize;
BlockRead(F, C, ReadSize);
for I:= 0 to ReadSize-1 do
if (C[I] < 32) and (not (C[I] in [9, 10, 13, 26])) then
begin
Result:= false;
Break;
end;
end;
finally
CloseFile(F);
end;
except
Result:= false;
end;
end;