MDI窗体值问题
老师要求用MDI窗体,我稍微用了下面一段代码:
string time = System.DateTime.Now.ToShortTimeString();
RichTextBox rtb_temp = (RichTextBox)this.ActiveMdiChild.ActiveControl;
//Form f_temp=this .ActiveMdiChild ;
f_=new f_child();
//f_.n = this;
string text =f_.SendText (this ); //SendText()方法是子窗体自定义的一个传递richTextBox的Text的方法.
string s = "保存" + System.DateTime.Now.ToLongDateString ()+".txt";
s = @"C:\Documents and Settings\Lok'Tar ogar\桌面\" + s;
FileStream f = new FileStream(s, FileMode.Append);
StreamWriter sw = new StreamWriter(f, System.Text.Encoding.GetEncoding("utf-8"));
sw.Write('\n'+time + '\r'+"写" + text);
sw.Close();
f.Close();
MessageBox.Show("文件保存成功!");
上面是个保存子窗体的richTextBox内容的代码,将其放在父窗体中的保存按钮事件当中,可这样做无法将richTextBox中的值保存到txt文档中,请帮我这个我想不出个所以然的问题,谢谢!