winform如何获取记事本内容显示在listBox控件中

//Application.StartupPath为获取当前exe文件所在位置的根目录

//“写入记事本文件的名字”

StreamReader sr = new StreamReader(Application.StartupPath + "\\Logs\\报警记录.txt");

while (sr.Peek() != -1)
{
listBox1.Items.Add(sr.ReadLine().Trim());
}

猜你喜欢

转载自www.cnblogs.com/z55w/p/10398093.html