没有合适的资源?快使用搜索试试~ 我知道了~
C#开发记事本工具实例
需积分: 9 1 下载量 169 浏览量
2012-03-02
10:25:34
上传
评论
收藏 7KB TXT 举报
温馨提示
试读
7页
一个简单的记事本代码!各位刚入行的同学可以学习参考一下。
资源推荐
资源详情
资源评论
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace T2
{
public partial class Form1 : Form
{
string filename = "";
const string defaultfilename = "unit";
public Form1()
{
InitializeComponent();
}
private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (filename == defaultfilename) //首次存盘时名相同都为unit存过一次后就不相同了
{
if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFileDialog1.FileName != "")
{
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace T2
{
public partial class Form1 : Form
{
string filename = "";
const string defaultfilename = "unit";
public Form1()
{
InitializeComponent();
}
private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (filename == defaultfilename) //首次存盘时名相同都为unit存过一次后就不相同了
{
if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFileDialog1.FileName != "")
{
System.IO.StreamWriter dout = new System.IO.StreamWriter(saveFileDialog1.FileName, false, System.Text.Encoding.Default);
string tempstr;
int i;
for (i = 0; i <= textBox1.Lines.Length - 1; i++)
{
tempstr = textBox1.Lines[i];
dout.WriteLine(tempstr);
}
dout.Close();
filename = saveFileDialog1.FileName;
}
}
else
{
System.IO.StreamWriter dout = new System.IO.StreamWriter(filename, false, System.Text.Encoding.Default);
string tempstr;
int i;
for (i = 0; i <= textBox1.Lines.Length - 1; i++)
{
tempstr = textBox1.Lines[i];
dout.WriteLine(tempstr);
}
dout.Close();
}
}
private void 打开ToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK && openFileDialog1.FileName != "")
{
string tempstr;
int i;
for (i = 0; i <= textBox1.Lines.Length - 1; i++)
{
tempstr = textBox1.Lines[i];
dout.WriteLine(tempstr);
}
dout.Close();
filename = saveFileDialog1.FileName;
}
}
else
{
System.IO.StreamWriter dout = new System.IO.StreamWriter(filename, false, System.Text.Encoding.Default);
string tempstr;
int i;
for (i = 0; i <= textBox1.Lines.Length - 1; i++)
{
tempstr = textBox1.Lines[i];
dout.WriteLine(tempstr);
}
dout.Close();
}
}
private void 打开ToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK && openFileDialog1.FileName != "")
{
剩余6页未读,继续阅读
资源评论
malove007
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功