procedure TForm1.Button1Click(Sender: TObject);
var
fs: TFileStream;
ms: TMemoryStream;
b: byte;
begin
OpenDialog1.InitialDir:=ExtractFilePath(Application.ExeName);
if OpenDialog1.Execute then begin
fs:=TFileStream.Create(OpenDialog1.FileName, fmOpenRead);
fs.Read(b, 1);
fs.Position:=0;
if b=$FF then begin
ms:=TMemoryStream.Create;
ObjectResourceToText(fs, ms);
ms.Position:=0;
ListBox1.Items.LoadFromStream(ms);
ms.Free;
Label1.Caption:='Type: Binary';
end else begin
ListBox1.Items.LoadFromStream(fs);
Label1.Caption:='Type: Text';
end;
fs.Free;
end;
end;