怎么用Winform读取Txt文件并实现电子书分页, 5
1个回答
展开全部
下面是读取txt文本方法:
public void ReadTxt(){
string helptxtPath = AppDomain.CurrentDomain.BaseDirectory + "help.txt";//这是我的文本路径
StreamReader streamopen = new StreamReader(helptxtPath, System.Text.Encoding.Default);
string strOpen=streamopen.ReadToEnd();
this.TextBox1.Text = strOpen;
streamopen.Close();
}
下面是逐行读取:
private void ReadTxt(){
string[] stringlines = File.ReadAllLines("d:\\a.txt",Encoding.Default);
foreach (string s in stringlines)
{
this.richTextBox1.Text += s;
}
}
public void ReadTxt(){
string helptxtPath = AppDomain.CurrentDomain.BaseDirectory + "help.txt";//这是我的文本路径
StreamReader streamopen = new StreamReader(helptxtPath, System.Text.Encoding.Default);
string strOpen=streamopen.ReadToEnd();
this.TextBox1.Text = strOpen;
streamopen.Close();
}
下面是逐行读取:
private void ReadTxt(){
string[] stringlines = File.ReadAllLines("d:\\a.txt",Encoding.Default);
foreach (string s in stringlines)
{
this.richTextBox1.Text += s;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询