16,721
社区成员
发帖
与我相关
我的任务
分享 string path = @"D:\3.txt";//读取文件txt
StringBuilder sb = new StringBuilder();
int index = 0;//存放第几行。
using (FileStream fs = new FileStream(path, FileMode.Open))
{
using (StreamReader sr = new StreamReader(fs))
{
while (!sr.EndOfStream)
{
index++;//循环一遍+1,大于1就是第二行
string sLine = sr.ReadLine();
if (sLine.Length < 1)
{
continue;
}
if (index > 1)
{
string[] test1 = sLine.Split(';');
foreach (string s in test1)
{
sb.Append(s.Trim() + "</br>");
}
}
}
}
}
Response.Write(sb.ToString());