我有这个代码,但它不工作。我尝试了几个不同的版本,但没有任何效果。我是一个新手,仍然不明白一切。
OpenFileDialog filedialog = new OpenFileDialog();
private void button3_Click(object sender, EventArgs e)
{
filedialog.ShowDialog();
filedialog.FileOk += filedialog_FileOk;
}
void filedialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
using (StreamReader myStream = new StreamReader(filedialog.FileName))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = myStream.ReadLine()) != null)
{
listBox1.Items.Add(line);
}
}
}
我认为这个编辑器需要大量纯文本。