using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string filename = @"E:\datread\kg.dat";
string line;
string[] stringArray;
try
{
using (StreamReader sr = new StreamReader(filename, Encoding.Default))
{
while ((line = sr.ReadLine()) != null)
{
stringArray = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < stringArray.Length; i++)
{
Response.Write(i + "的值是:" + stringArray[i]+"<br />");
}
}
}
}
catch (Exception ex)
{
Response.Write("The file could not be read:");
Response.Write(ex.Message);
}
}
}
C#读取txt文本文件(dat)的方法
最新推荐文章于 2024-01-10 09:18:33 发布