473,657 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving from richTextBox to File

JRB
Hi, I've got a bunch of text put onto a richTextBox with a StreamWriter.
Every now and then I insert a '\n' character for a new line. It displays
properly in the richTextBox with the \n character moving the text down to the
next line. The problem is that I have it set up so when the user clicks a
button I want to be able to save everything on the richTextBox to a file. It
works properly, but when I view the text file with Notepad, the \n characters
show up as squares instead of moving the text down to the next line. What is
the reason for this and can anyone help?
Nov 16 '05 #1
4 7535
Try inserting a '\r' character before the '\n'

'\n' is unix style line ending.

Windows uses CR+LF (Carriage Return + Line Feed). That would be "\r\n"

-vJ

"JRB" <JR*@discussion s.microsoft.com > wrote in message
news:93******** *************** ***********@mic rosoft.com...
Hi, I've got a bunch of text put onto a richTextBox with a StreamWriter.
Every now and then I insert a '\n' character for a new line. It displays
properly in the richTextBox with the \n character moving the text down to
the
next line. The problem is that I have it set up so when the user clicks a
button I want to be able to save everything on the richTextBox to a file.
It
works properly, but when I view the text file with Notepad, the \n
characters
show up as squares instead of moving the text down to the next line. What
is
the reason for this and can anyone help?

Nov 16 '05 #2
Consider System.Environm ent.NewLine

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
JRB
Hi guys, thanks for the responses. I've tried both these solutions, but they
don't work. It might be a problem with Notepad or something because if I use
Wordpad to view the output it's formatted correctly. For some reason Notepad
interprets the newline as a character literal. The thing that's got me is
that if I make a call to StreamWriter.Ne wLine when writing to a file it does
give me a new line rather than the square character. From my understanding
StreamWriter.Ne wLine simply adds a "\r\n" to the end of what it's writing. So
how come when I add "\r\n" to the end of my strings manually it doesn't work?
What gives? Thanks in advance.

JRB

"Jeff Louie" wrote:
Consider System.Environm ent.NewLine

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4
If you post a snippet of your code, then, we can try and figure out what's
going on.

-vJ

"JRB" <JR*@discussion s.microsoft.com > wrote in message
news:EC******** *************** ***********@mic rosoft.com...
Hi guys, thanks for the responses. I've tried both these solutions, but
they
don't work. It might be a problem with Notepad or something because if I
use
Wordpad to view the output it's formatted correctly. For some reason
Notepad
interprets the newline as a character literal. The thing that's got me is
that if I make a call to StreamWriter.Ne wLine when writing to a file it
does
give me a new line rather than the square character. From my understanding
StreamWriter.Ne wLine simply adds a "\r\n" to the end of what it's writing.
So
how come when I add "\r\n" to the end of my strings manually it doesn't
work?
What gives? Thanks in advance.

JRB

"Jeff Louie" wrote:
Consider System.Environm ent.NewLine

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1890
by: gogaz | last post by:
Hello, I am facing one strange problem. I am using RichTextBox control in my VB6.0 application and have provided one button giving functionality to set bullets on the selected text. When i type and set bullets on some text and save the document, it is displaying everything ok. But when i open the saved file again I notice some small dots in the line before and after the bulleted text.
1
1337
by: David Johnston | last post by:
I am converting to the .NET platform and I am starting with C#. Just for exercise I'm writing a text editor and I am having some problems with saving files. I am using a single document interface system. I am just working with plain text now but I was wondering what differences I would have to make to save between .txt, .rtf, or even .doc if possible. Thanks for any help you could give or examples you could point me to . Thanks again.
0
2382
by: AxOn | last post by:
Hi! I'm having trouble creating a save funktion. How can I save the contens of a new richTextBox that is created from an "external" class file? The open funktion looks like this: public void openFile() { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "Select a Text File";
8
3261
by: AxOn | last post by:
Hi, How can i save the specific RichTextBox in the selected tab if i have several tabs with RichTextBoxes in? The application is a text editor type program and when i try to save the most recently opened text file in the rich text box my application saves that file over the other files?? Can i some how index the new RichTextBoxes so that only the text in the selected RichTextBox is saved??
3
2180
by: AxOn | last post by:
Hi, I have an application with a Save function. I want to be able to have several tabs(each containing a RichTextBox, created at runtime) open in a tabControl and save the text from each RichTextBox one at a time. The plain text is loaded into the RichTextBoxes via an openFile funktion that creates a new RichTextBox. When the file is opened the name of the new RichTextBox and the name of the file is stored in a Hashtable like so:
1
1700
by: bmerlover | last post by:
I'm having trouble reading quotations inside the richTextBox when a file is opened on to it. I've tried a couple different methods, most of them didn't compile. I came across one that does compile and supposedly it's suppose to work but it doesn't in my case. I tried this code to see if it would recognize the quotations. For testing purpose I wanted to see if it would start the string from the quotation. str =...
0
1390
Ajm113
by: Ajm113 | last post by:
Contributing To: Saving RichTextBox from Tab Control Ok, I have a question what would I use if I wanted to do something like a paste function in a Rich Text Box using the code on that thread? Thanks, Ajm113.
0
778
latitude
by: latitude | last post by:
I have this little code: private void notePage1_KeyUp(object sender, KeyEventArgs e) { notePage1.SaveFile(Application.StartupPath +@"\fxNotesText1.Rtf"); } Need to know if there would be an easy way to encrypt the text from the richtextbox called notepage1 before it saves? Would also be good if it did it when exiting the application, like:
1
1258
by: =?Utf-8?B?TWFya19C?= | last post by:
I have an unpredictable number of RichTestBoxes, stored in a generic list, that are created at runtime. Currently, I am saving these controls to a file by saving each attribute of each box in string form using a streamwriter. Later, these attributes are read from the file with a streamreader and the controls are recreated. It seems like a cumbersome, inelegant, and inefficient way to save. Is there another way of saving the entire...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.