473,383 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

saving rich text box data!

Lee
Hi,

I have a rich text box that can have hyperlinks ect within the text!

when I save this data to file how should I do it? that is can I just save it
as text?

or do I need to serialize it beforehand to preserve the hyperlink info?

thanks in advance
Mar 20 '06 #1
5 8156
> when I save this data to file how should I do it? that is can I just save
it as text?

If your rich text box is called "richTextBox1", you can load a file like
this:

this.richTextBox1.LoadFile("C:\\Document.rtf");

and save the content with this line:

this.richTextBox1.SaveFile("C:\\newFile.rtf");

Regards,
Lars-Inge Tønnessen
Mar 20 '06 #2
Lee
sorry I wasn't very clear,

I am saving the rich text box data as part of an xml file.

thanks
"Lars-Inge Tønnessen (VJ# MVP)" <http://emailme.larsinge.com> wrote in
message news:Ok**************@tk2msftngp13.phx.gbl...
when I save this data to file how should I do it? that is can I just save
it as text?

If your rich text box is called "richTextBox1", you can load a file like
this:

this.richTextBox1.LoadFile("C:\\Document.rtf");

and save the content with this line:

this.richTextBox1.SaveFile("C:\\newFile.rtf");

Regards,
Lars-Inge Tønnessen

Mar 20 '06 #3
You get the raw rtf from the "Rtf" method (this.richTextBox1.Rtf).
You would have to code this rtf formatted text into characters that XML can
store. XML can not store all charaters.

Format the rtf as Base64.

this.richTextBox1.LoadFile("C:\\Document.rtf");
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
string StoreMe =
System.Convert.ToBase64String(enc.GetBytes(this.ri chTextBox1.Rtf));
System.Windows.Forms.MessageBox.Show(StoreMe);

Regards,
Lars-Inge Tønnessen
Mar 20 '06 #4
Lee
thanks.. but!

how on earth do I read the Base64 data back into a string?

thanks
"Lars-Inge Tønnessen (VJ# MVP)" <http://emailme.larsinge.com> wrote in
message news:eL**************@TK2MSFTNGP14.phx.gbl...
You get the raw rtf from the "Rtf" method (this.richTextBox1.Rtf).
You would have to code this rtf formatted text into characters that XML
can store. XML can not store all charaters.

Format the rtf as Base64.

this.richTextBox1.LoadFile("C:\\Document.rtf");
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
string StoreMe =
System.Convert.ToBase64String(enc.GetBytes(this.ri chTextBox1.Rtf));
System.Windows.Forms.MessageBox.Show(StoreMe);

Regards,
Lars-Inge Tønnessen

Mar 21 '06 #5
> how on earth do I read the Base64 data back into a string?

Like this:

this.richTextBox1.LoadFile("C:\\Document.rtf");

// From RTF to Base64
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
string StoreMe =
System.Convert.ToBase64String(enc.GetBytes(this.ri chTextBox1.Rtf));
System.Windows.Forms.MessageBox.Show(StoreMe);

// Back from Base64 to RTF
byte[] result = System.Convert.FromBase64String(StoreMe);
string RTFString = enc.GetString(result);
System.Windows.Forms.MessageBox.Show(RTFString);
Regards,
Lars-Inge Tønnessen
Mar 21 '06 #6

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

Similar topics

1
by: PC User | last post by:
I found this Rich Text Editor and I've been trying to recreate it in my own application. I've had trouble with the COMCTL.ImageListCtrl and the COMCTL.Toolbar to recreate the toolbar. And I've...
1
by: Peter | last post by:
I have written a small terminal app that reads and writes to the serial port. In particular as the data is read from the serial port it is appended to the rich text box. The problem I am...
8
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...
1
by: tomi.trescak | last post by:
Hi I have a problem with storing rich text in MySQL. I store rich text in MySQL (in column with type "text") which i get from Rich Textbox control. When i do reverse processing by trying to...
5
by: ARC | last post by:
Just found out something interesting with Access 2007... In table design, if you set a memo field to the new rich text option, and put that control on a form, set the control to rich text, you can...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
0
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?...
0
by: Michelle Monty | last post by:
Hi, I'm trying to create a program where the user can enter check information and the information is saved to a sequential access file. I'm getting an error when I run the program. The error is...
2
by: Michelle Monty | last post by:
Hi, I'm trying to create a program where the user can enter check information and the information is saved to a sequential access file. I'm getting an error when I run the program. The error is...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.