【发布时间】:2022-10-07 19:15:36
【问题描述】:
我有一个包含文本的文件,我可以让它在页面加载时填充一个文本框,但它总是添加一个空白的第一行。有任何想法吗?我尝试跳过数组中的第一行,以防它为空白(0 和 1),但 0 什么也不做, 1 跳过文本文件中的第一行。
我还尝试将文本框设置为 null 和“”,以防它以某种方式附加到文本框。
//Populating the contents box
string[] str = null;
if (File.Exists(docPath + prefix + libIDPath + "\\" + oldFileName))
{
str = File.ReadAllLines(docPath + prefix + libIDPath + "\\" + oldFileName);
//str = str.Skip(0).ToArray();
//FDContentsBox.Text = null;
}
foreach (string s in str)
{
FDContentsBox.Text = FDContentsBox.Text + "\n" + s;
}
【问题讨论】: