我正在尝试将文本文件中的文本行加载到我的表单加载列表框中我已经使用此代码:
string[] lines = File.ReadAllLines(sPath);
listBox1.Items.AddRange(lines);
但是编译器给了我一个错误enter image description here
我正在尝试将文本文件中的文本行加载到我的表单加载列表框中我已经使用此代码:
string[] lines = File.ReadAllLines(sPath);
listBox1.Items.AddRange(lines);
但是编译器给了我一个错误enter image description here
1 回答
简单的答案是
sPath
为null,无论您在何处设置它,请确保它具有值或运行代码 .另请学习使用调试器来帮助识别您的问题和解决方案
Navigate Code with the Visual Studio Debugger