展开全部
记事本总得来讲不难,,
记事本不外乎就打开、保存、复制、剪切、粘贴等几项主要功能,
我都给你写写
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "基本格式|*.txt;*.doc";
ofd.RestoreDirectory = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
using (FileStream fs = new FileStream(ofd.FileName,FileMode.Open,FileAccess.Read))
{
StreamReader sr = new StreamReader(fs, Encoding.Default);
textBox1.Text = sr.ReadToEnd();
}
}
———————————————打开代码—————————————————
SaveFileDialog sfd = new SaveFileDialog();
sfd.RestoreDirectory = false;
sfd.Filter = "文本格式|*.txt";
if (sfd.ShowDialog() == DialogResult.OK)
{
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, Encoding.Default);
sw.Write(textBox1.Text);
sw.Flush();
sw.Close();
}
}
———————————————保存代码—————————————————
textBox1.Copy();
textBox1.Cut();
textBox1.Paste();
等等很多,详细你可以自己去看看
记事本不外乎就打开、保存、复制、剪切、粘贴等几项主要功能,
我都给你写写
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "基本格式|*.txt;*.doc";
ofd.RestoreDirectory = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
using (FileStream fs = new FileStream(ofd.FileName,FileMode.Open,FileAccess.Read))
{
StreamReader sr = new StreamReader(fs, Encoding.Default);
textBox1.Text = sr.ReadToEnd();
}
}
———————————————打开代码—————————————————
SaveFileDialog sfd = new SaveFileDialog();
sfd.RestoreDirectory = false;
sfd.Filter = "文本格式|*.txt";
if (sfd.ShowDialog() == DialogResult.OK)
{
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, Encoding.Default);
sw.Write(textBox1.Text);
sw.Flush();
sw.Close();
}
}
———————————————保存代码—————————————————
textBox1.Copy();
textBox1.Cut();
textBox1.Paste();
等等很多,详细你可以自己去看看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询