循环txt文本的每一行数据输出
System.IO.StreamReader file = new System.IO.StreamReader(Application.StartupPath + "\\AlarmSet.txt");
string line;
while ((line = file.ReadLine()) != null)
{
if (!string.IsNullOrWhiteSpace(line))
{
content += line.Replace("<", "<").Replace(">", ">") + "</br>" + "\r";
}
}
循环输出字符串的每一行数据
string text = @"
First line
second line
third line";
using (var reader = new StringReader(text))
{
for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
{
// Do something with the line
}
}