Can someone please tell me why i am getting an invalid file format
exception? here is the code:
string temp = rtbRTF.Rtf;
if (temp.Contains("<font") || temp.Contains("<b>") || temp.Contains("<i>")
|| temp.Contains("<P>") || temp.Contains("<br>"))
{
int start, x;
start = x = 0;
string sub;
while ((start = temp.IndexOf("<font color=#", start)) != -1)
{
x++;
start += 13;
sub = temp.Substring(start, temp.IndexOf(">", start) - start);
GetRGBFromHex(sub);
temp = temp.Replace("<font color=#" + sub + ">", "\\cf" + x.ToString());
start = temp.IndexOf(">", start) + 1;
}
temp = temp.Insert(0, clrtbl);
temp = temp.Replace("</font>", "\\cf0");
temp = temp.Replace(" ", "\\tab");
temp = temp.Replace("</i>", "\\i0");
temp = temp.Replace("<i>", "\\i");
temp = temp.Replace("</u>", "\\ul0");
temp = temp.Replace("\\ul0", "\\ulnone");
temp = temp.Replace("<u>", "\\ul");
temp = temp.Replace("</b>", "\\b0");
temp = temp.Replace("<b>", "\\b");
temp = temp.Replace("</P><P>", "\\par");
temp = temp.Replace("<BR>", "\\line");
temp += "}";
rtbRTF.Rtf = temp;
}