c# - Saving plain text to RichText -
i'm little confused following code. i'm taking plain text stored in database , supplying text portion of richtextbox control saving file.
the first file blank though contain data.
richtextbox test = new richtextbox(); for(int = 0; < dt.rows.count; i++) { test.text = dt.rows[i][1].tostring(); string file_name = path.combine(path, dt.rows[i][0].tostring() + ".rtf"); test.savefile(file_name, richtextboxstreamtype.richtext); test.clear(); }
now work around though it's ugly did following , write first entry file correctly
bool run_once = true; richtextbox test = new richtextbox(); for(int = 0; < dt.rows.count; i++) { test.text = dt.rows[i][1].tostring(); string file_name = path.combine(path, dt.rows[i][0].tostring() + ".rtf"); test.savefile(file_name, richtextboxstreamtype.richtext); test.clear(); if (run_once) { file.delete(file_name); run_once = false; i--; } }
could shed light here?
interesting. "think" might bug. work-around:
using (richtextbox test = new richtextbox()) { (int = 0; < dt.rows.count; i++) { test.selectall(); test.text = dt.rows[i][1].tostring(); string file_name = path.combine(path, dt.rows[i][0].tostring() + ".rtf"); test.savefile(file_name, richtextboxstreamtype.richtext); test.clear(); } }
the selectall()
needed make bug go away. not sure why.
Comments
Post a Comment