473,419 Members | 1,884 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,419 software developers and data experts.

appending to rtf string problems

I am trying to build a test harness to practice appending strings to an rtf
string. I am doing this to simulate the string I'll be sending over the wire
and receiving on the other end of an IM application. Below is the code I use
to test.

I receive this error everytime I try to send the string from one rtb to
another:

"File Format is not valid Line 28" Line 28 is where I set rtb2 to the value
of the newly concatanated string----rtb2.Rtf =rtbBuild;

private void button1_Click(object sender, EventArgs e)
{
try
{
String msgCode = "101;";
String socketid = "2,";
String rtbVals = rtb1.Rtf.ToString();
String rtbBuild = msgCode + socketid + rtbVals;
rtb2.Rtf =rtbBuild;
}
catch (Exception excep)
{
MessageBox.Show(excep.ToString());
}

}

any ideas as to why I'm receivng this error? Thanks for any help!
Nov 17 '05 #1
1 2696
Mike,

The reason this happens is because you are adding text to the rtf text
and trying to reassign it ot the Rtf property. Rtf is like Xml in the sense
that there are delimiters before and after the content, and you can't just
add something wherever you want in the string that makes up the RTF text.

What you need to do is strip away the message code and the socket id
before you set the Rtf property on the rich text box.
Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"mikemac76" <mi*******@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
I am trying to build a test harness to practice appending strings to an rtf
string. I am doing this to simulate the string I'll be sending over the
wire
and receiving on the other end of an IM application. Below is the code I
use
to test.

I receive this error everytime I try to send the string from one rtb to
another:

"File Format is not valid Line 28" Line 28 is where I set rtb2 to the
value
of the newly concatanated string----rtb2.Rtf =rtbBuild;

private void button1_Click(object sender, EventArgs e)
{
try
{
String msgCode = "101;";
String socketid = "2,";
String rtbVals = rtb1.Rtf.ToString();
String rtbBuild = msgCode + socketid + rtbVals;
rtb2.Rtf =rtbBuild;
}
catch (Exception excep)
{
MessageBox.Show(excep.ToString());
}

}

any ideas as to why I'm receivng this error? Thanks for any help!

Nov 17 '05 #2

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

Similar topics

7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
2
by: Robizzle | last post by:
I am having problems appending a number to the end of a string. I searched google and google forums and couldn't figure it out .... sorry i'm sure its simple. so I have: $filename =...
16
by: Michael | last post by:
I have a data application in a2k that I need to create two fixed width text files and then combine them to a single file The first file is header information and the second is transaction data. ...
2
by: Cat | last post by:
How do you go about appending data from a dataset to an existing xml file? I know you can use WriteXML but this writes over any data already existing in the specified file.. Cat
18
by: Paul Roberts | last post by:
Hiya I have a string with about 300+ characters, how can i insert a line break or another character every 50 characters for the whole string? Paul Roberts
1
by: libsfan01 | last post by:
hello again! another problem im having is appending a value to a string. how come this function isnt working for me? string overwrites the value of content not gets added onto the end of it?! ...
10
by: rory | last post by:
I can't seem to append a string to the end of a binary file. I'm using the following code: fstream outFile("test.exe", ios::in | ios::out | ios::binary | ios::ate | ios::app)...
1
by: ofuuzo1 | last post by:
Hei, I am having issue using DOM to appending a new xml file (new.xml) to another existing xml file (old.xml) without deleting the existing items in old.xml. I would like to have the new...
1
by: KiddoGuy | last post by:
I am trying to build a string character by character. However, when I use the overloaded += or string.append() method, the character replaces the one before it rather than appending to it so I am...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.