记事本/Form1.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;
// 下载于www.51aspx.com
namespace 记事本
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string str = "";
//打开文件
private void 打开OToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog();//初始化
openfile.Filter = "txt文件(*.txt)|*.txt";//文件类型过滤
Stream mystream = null;
if (openfile.ShowDialog() == DialogResult.OK)
{
try//异常处理
{
if ((mystream = openfile.OpenFile()) != null)
{
StreamReader sr = new StreamReader(mystream);
string str = sr.ReadLine();//一行一行的读取
while (str != null)//只要该行不为空
{
richTextBox1.AppendText(str);//将文本添加到控件中去
richTextBox1.AppendText("\n");//读取一行后换行
str = sr.ReadLine();//读取下一行
}
}
}
catch (Exception ex)
{
MessageBox.Show("文件打开出错"+ex.Message);
}
}
}
private void 新建NToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog();
openfile.Filter = "txt文件(*.txt)|*.txt";
后面还有 199 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。