moonrise
asked on
RichEdit - detecting RTF ot Text format
I wrote a small word processor using TRichEdit. I want the users to be able to open RTF documents and Text document without having to specify the type themselves. If I set the RichEdit to one type and try to open the other type I get errors.
Is there a way to look at a file before opening it and see if it is plain text or RTF.
Is there a way to look at a file before opening it and see if it is plain text or RTF.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both.
Probably this is the only way to check that....Just to help you with the coding....
function rtf(Filename : string):Boolean;
var
F : TextFile;
Line : string;
begin
AssignFile(f, Filename);
Reset(F);
ReadLn(f, Line);
Result := Pos('{\rtf1\', Line);
CloseFile(F);
end;
Example Call:
If RTF('C:\windows\desktop\te
//Set it for rtf
else
//Set it not for rtf
Hope this helps =)
Regards,
Viktor Ivanov