Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Count lines in rtf files with c# [modified]

Count lines in rtf files with c# [modified]

Scheduled Pinned Locked Moved C#
csharpquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    panoskatws
    wrote on last edited by
    #1

    Hi all, I am trying to find a way to count lines in an rtf file, so I could later create a kind of paging. I am using c#, also is there a way to show a string that includes format characters (such as "/par" in rtf) in a richTextBox? Thanks!!! Panos

    modified on Thursday, March 13, 2008 1:59 PM

    L L 2 Replies Last reply
    0
    • P panoskatws

      Hi all, I am trying to find a way to count lines in an rtf file, so I could later create a kind of paging. I am using c#, also is there a way to show a string that includes format characters (such as "/par" in rtf) in a richTextBox? Thanks!!! Panos

      modified on Thursday, March 13, 2008 1:59 PM

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      panoskatws wrote:

      Hi all, I am trying to find a way to count lines in an rtf file

      There may be a library that will do that for you, I don't know. Otherwise to write your own code to do anything with a specific file format you start by learning the file format. So if that is what you intend to do then go find some documentation for the RTF file format and learn it.

      led mike

      P 1 Reply Last reply
      0
      • P panoskatws

        Hi all, I am trying to find a way to count lines in an rtf file, so I could later create a kind of paging. I am using c#, also is there a way to show a string that includes format characters (such as "/par" in rtf) in a richTextBox? Thanks!!! Panos

        modified on Thursday, March 13, 2008 1:59 PM

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        The RichTextbox not working for you?

        xacc.ide - now with IronScheme support
        IronScheme - 1.0 alpha 2 out now

        P 1 Reply Last reply
        0
        • L led mike

          panoskatws wrote:

          Hi all, I am trying to find a way to count lines in an rtf file

          There may be a library that will do that for you, I don't know. Otherwise to write your own code to do anything with a specific file format you start by learning the file format. So if that is what you intend to do then go find some documentation for the RTF file format and learn it.

          led mike

          P Offline
          P Offline
          panoskatws
          wrote on last edited by
          #4

          Well about libraries I haven't found anything that I can use. So I must create my own piece of code that counts lines and takes specific parts of formated text and display it in a RichTextBox, formated... That is an other problem I have, don't know how to display a part of formated text without loosing the styling(fonts, colors etc.). All special characters are displayed with the text (/n ...). So I understand that I must learn about the rtf file format. Does anyone know the basics that are needed, or any suggestions??? Thanks!!!

          1 Reply Last reply
          0
          • L leppie

            The RichTextbox not working for you?

            xacc.ide - now with IronScheme support
            IronScheme - 1.0 alpha 2 out now

            P Offline
            P Offline
            panoskatws
            wrote on last edited by
            #5

            It's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?

            L L L 3 Replies Last reply
            0
            • P panoskatws

              It's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              panoskatws wrote:

              It's working fine, but I have a problem with displaying the text formated from a string variable.

              Be more specific. 1) Are you having a problem displaying the text with formatting in the RichTextBox control? If so provided details regarding the problem. 2) Are you saying you want to display it in some way other than using the RichTextBox? If so provide specifically how you want to do that.

              led mike

              1 Reply Last reply
              0
              • P panoskatws

                It's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?

                L Offline
                L Offline
                leppie
                wrote on last edited by
                #7

                2 ways: 1. Place the string in a MemoryStream, then Load the stream, the RichTextBox should detect it is RTF. 2. Place the string in the clipboard, set its format to RTF, then paste that object to the RichTextBox. I wouldnt normally suggest a way like #2, but as the 1st method will overwrite all the current content (and that may not be desirable), I do mention it.

                xacc.ide - now with IronScheme support
                IronScheme - 1.0 alpha 2 out now

                1 Reply Last reply
                0
                • P panoskatws

                  It's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?

                  L Offline
                  L Offline
                  Lutoslaw
                  wrote on last edited by
                  #8

                  If I understood you correctly, you can set the Rtf property of a RichTextBox to this string and then you can get lines count through Lines.Length.

                  Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups