var
aa: TMemoryStream;
i: Integer;
ab: array[0..0] of Byte;
begin
aa := TMemoryStream.Create;
try
aa.Loadfromfile('aaa.txt');
for i := 0 to aa.Size - 1 do
begin
aa.Position := i;
aa.Read(ab, 1);
if ab[0] > 128 then
begin
ShowMessage('bin文件');
Exit;
end;
end;
ShowMessage('txt文件');
finally
aa.Free;
end;
end;