Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I need to know if a RTF has a real text content such as at least one char, space or carriage return and it is not completly empty. The length doesn't matter!

I do not want to check this by converting the whole text into plaintext and examine the text length or using a special control.

For example is there any way using RegEx on the raw RTF text or something like that to check this?

Thanks and Regards,

Michael
Posted

1 solution

Not that it will help you but I cannot think of any easy way to do this.

As a quick experiment I created a blank rtf file in OpenOffice and when saved it was 3kb. Another one created in Word was 2kb. The file size is therefore not a reliable guide.

I haven't tested this but the Windows Forms RichTextBox control has a TextLength property, so theoretically you could create an in-memory RichTextBox, load in the file and read the TextLength. As I say, I haven't tested it and am therefore not sure if the length returned is accurate.

Good luck. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900