asp.net 按行读取包含中文的文本(txt)文件并取得行数
2007-06-14 23:54
393 查看
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string Path = Server.MapPath("4.txt");
insertStr(Path);
}
}
public void insertStr(string Path)
{
string strLine = "";
int i = 0;
try
{
StreamReader sr = new StreamReader(Path, Encoding.GetEncoding("GB2312"));
strLine = sr.ReadLine();
while (strLine != null)
{
Response.Write(strLine + "<br>");
strLine = sr.ReadLine();
i++;
}
Response.Write(i);
sr.Dispose();
sr.Close();
}
catch
{
}
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string Path = Server.MapPath("4.txt");
insertStr(Path);
}
}
public void insertStr(string Path)
{
string strLine = "";
int i = 0;
try
{
StreamReader sr = new StreamReader(Path, Encoding.GetEncoding("GB2312"));
strLine = sr.ReadLine();
while (strLine != null)
{
Response.Write(strLine + "<br>");
strLine = sr.ReadLine();
i++;
}
Response.Write(i);
sr.Dispose();
sr.Close();
}
catch
{
}
}
}
相关文章推荐
- asp.net 按行读取包含中文的文本(txt)文件并取得行数
- asp.net 按行读取包含中文的文本(txt)文件并取得行数
- asp.net从数据库导出数据到word、excel、txt文本文件
- asp.net实现从Txt文件读取数据到数据视图的方法
- asp.net实现从Txt文件读取数据到数据视图的方法
- asp.net动态生成txt文本文件供用户下载
- asp.net读取当前application下的txt文件路径
- asp.net读取和写入txt文件方法
- asp.net(c#)如何读取上传过程中的.txt文件中的数据,并将其写入数据库的
- asp.net从数据库导出数据到word、excel、txt文本文件
- asp.net mvc中读取input file上传的txt文件内容,但不需要把文件保存到服务器上
- asp.net 将文本转化为文本文件txt文件
- ASP.NET Web Pages基础知识---从文本文件中读取并显示数据
- ASP批量按行读取记事本txt文字添加到SQL数据库_逐行读取文本txt到数据库
- 如何解决ASP.NET下载时的中文文件名乱码,与TXT文件中存在代码两个问题
- asp.net读取txt文件内容
- 请教Ado.Net按文本读取CSV/Txt文件时,如何禁止将内容转换成数字
- ASP.NET对txt文件相关操作(读取、写入、保存)
- c#asp.net 读取 写入 txt 文件 asp.net操作文件
- asp.net读取txt文件内容