winforms - format text in richtextbox when using stream reader to read in file c# -


i have richtextbox reading text file using streamreader on button click have formatted text file way want displayed within text file using paragraphs when add text richtextbox formatting disappears. there way can format text separate paragraphs when reading textbox text file?

here code:

         using (streamreader reader = new streamreader(@"f:\test.txt"))           {               bool content = false;               while ((line = reader.readline()) != null)             {                  if (line.contains("[7]"))                 {                     content = true;                     continue;                  }                 if (content == true)                 {                      txtcontent.appendtext(line.replace("[7]", "").replace("[/7]", ""));                  }                 if (line.contains("[/7]"))                 {                     content = false;                     break;                 }               }           } 

the [7] , [/7] refer tag have added textfile reader reads inbetween these tags , displays chosen text inbetween

thanks

the string returned streamreader.readline() not contain terminating carriage return or line feed. need manually append richtextbox @ end of each line:

                txtcontent.appendtext(line.replace("[7]", "").replace("[/7]", ""));                 txtcontent.appendtext(environment.newline); 

Comments

Popular posts from this blog

r - Trouble relying on third party package imports in my package -

Payment information shows nothing in one page checkout page magento -