form1.cs
来自「C#高级编程第6版随书源代码 值得下载」· CS 代码 · 共 39 行
CS
39 行
using System;
using System.IO;
using System.Security;
using System.Windows.Forms;
namespace SimpleExample
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void OnLoadData(object sender, EventArgs e)
{
try
{
string filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "animals.txt");
using (StreamReader stream = File.OpenText(filename))
{
string str;
while ((str = stream.ReadLine()) != null)
{
listAnimals.Items.Add(str);
}
}
}
catch (SecurityException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?