2个回答
2013-11-09
展开全部
如果你用RichTextBox做,可使用SaveFileDialog和RichTextBox中的SaveFile()方法,如果是用TextBox做,那还需要做存储文件的功能。
具体代码,使用RichTextBox:
SaveFileDialog s=new SaveFileDialog();
SaveFileDialog s = new SaveFileDialog();
s.FileName = "";
s.Filter = "*.txt|Text Document|*.*|All Files";
s.DefaultExt = "txt";
if (s.ShowDialog() == DialogResult.OK && s.FileName != "")
{
richTextBox1.SaveFile(s.FileName);
}
使用TextBox:
SaveFileDialog s = new SaveFileDialog();
s.FileName = "";
s.Filter = "*.txt|Text Document|*.*|All Files";
s.DefaultExt = "txt";
if (s.ShowDialog() == DialogResult.OK && s.FileName != "")
{
FileStream file = new FileStream(s.FileName, FileMode.Create, FileAccess.Write);
StreamWriter writer = new StreamWriter(file);
writer.Write(textBox1.Text);
writer.Flush();
writer.Close();
file.Close();
}
具体代码,使用RichTextBox:
SaveFileDialog s=new SaveFileDialog();
SaveFileDialog s = new SaveFileDialog();
s.FileName = "";
s.Filter = "*.txt|Text Document|*.*|All Files";
s.DefaultExt = "txt";
if (s.ShowDialog() == DialogResult.OK && s.FileName != "")
{
richTextBox1.SaveFile(s.FileName);
}
使用TextBox:
SaveFileDialog s = new SaveFileDialog();
s.FileName = "";
s.Filter = "*.txt|Text Document|*.*|All Files";
s.DefaultExt = "txt";
if (s.ShowDialog() == DialogResult.OK && s.FileName != "")
{
FileStream file = new FileStream(s.FileName, FileMode.Create, FileAccess.Write);
StreamWriter writer = new StreamWriter(file);
writer.Write(textBox1.Text);
writer.Flush();
writer.Close();
file.Close();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-11-09
展开全部
用System.IO做呗。
控件,自己看着办呗,至少有个 textarea吧
控件,自己看着办呗,至少有个 textarea吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询