In my application, I search the database for a string that contains RTF and needs to load it into ASPxRichEdit. And, when necessary, save the contents of the ASPxRichEdit into an RTF string to store in the database. How can I do this in C #?
I managed indirectly by creating files to open / save, but it is unfeasible because of performance. That is, the form below is impractical.
file.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
string rtf = BuscaTexto();
string open = @"Projects/PCMSO/PCMSO/App_Data/WorkDirectory/open" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".rtf";
StreamWriter writer = new StreamWriter(open);
writer.WriteLine(rtf);
writer.Close();
ASPxRichEdit1.Open(open);
Delete(open);
}
public string Save()
{
string salvo = @"Projects/PCMSO/PCMSO/App_Data/WorkDirectory/save" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
ASPxRichEdit1.SaveCopy(salvo);
string rtf_string = System.IO.File.ReadAllText(salvo);
Delete(salvo);
return rtf_string;
}
file.aspx
<td>
<form runat="server">
<dx:ASPxRichEdit ID="ASPxRichEdit1" style="width: 100%; height: 400px" runat="server" WorkDirectory="~\App_Data\WorkDirectory"></dx:ASPxRichEdit>
</form>
</td>