各位高手,我想请教一个问题:如何把在richTextBox控件中显示的内容按照系统当时的年月日小时分钟保存?
各位编程高手,我是学习C#的学生,现有一个问题想请教大家,如何把在richTextBox控件中显示的内容按照系统当时的年月日小时分钟保存呢?谢谢大家啦~~~
源代码如下:
private void button5_Click(object sender, EventArgs e)
{
string spath = "F:\\Save As cuiyang0729.txt"; //保存的路径
string s = richTextBox2.Text.Trim().ToString();
string s1 = s;
FileStream stream = File.OpenWrite(spath);
byte[] by = Encoding.UTF8.GetBytes(s);
BinaryWriter writer = new BinaryWriter(stream);//写入文件
writer.Write(by, 0, by.Length);
writer.Close();
stream.Close();
}
------解决方案--------------------private void button5_Click(object sender, EventArgs e)
{
string spath = "F:\\Save As cuiyang0729.txt"; //保存的路径
string s = richTextBox2.Text.Trim().ToString();
string s1 = s + DateTime.Now.ToString();
FileStream stream = File.OpenWrite(spath);
byte[] by = Encoding.UTF8.GetBytes(s);
BinaryWriter writer = new BinaryWriter(stream);//写入文件
writer.Write(by, 0, by.Length);
writer.Close();
stream.Close();
}