C # Instrument data file parsing-rtf file

Source: Internet
Author: User

RTF files are not unfamiliar, but RTF file encoding, decoding is very difficult, because the RTF file is rich in text format, that is, in addition to the text content in the file, but also contains text format information, and this information does not like the subsequent docx, such as the use of XML to isolate the format and content, so decoding is difficult.

Some instrument data reports are exported in RTF format because RTF can be edited using WordPad, and the WordPad program is installed by default on Windows systems, so the output RTF file is easy to read and write.

Parsing RTF files, it is difficult to start from decoding, but can rely on the basic functionality of Windows to achieve rich text content acquisition, in particular, rely on the WinForm class library to read RTF file content, of course, this way can read the text content, picture, table style will be ignored.

The following is the sample code:

            RichTextBox Rtbox = new RichTextBox ();             string s = File.readalltext (fileName);             Rtbox.rtf = s;            string plaintext = Rtbox.text;             return plaintext;

  

C # Instrument data file parsing-rtf file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.