public string ReadFile(string TemplatePath)
{
//---------------------读html模板页面到stringbuilder对象里----
StringBuilder htmltext = new StringBuilder();
try
{
using (StreamReader sr = new StreamReader(TemplatePath, System.Text.Encoding.Default)) //模板页路径
{
String line;
while ((line = sr.ReadLine()) != null)
{
htmltext.Append(line);
}
sr.Close();
}
return htmltext.ToString();
}
catch(Exception ex)
{
return ""; }
} while ((line = sr.ReadLine()) != null)
{
htmltext.Append(line);
}这一段是读行,但是我现在TXT里是排好版的,如果读到TEXTBOX上就乱乱的,不是TXT里一样了...
所以我想一行一行的读TXT然后一行一行的放到TEXTBOX里,这样就不会乱了...
该怎么改...
{
//---------------------读html模板页面到stringbuilder对象里----
StringBuilder htmltext = new StringBuilder();
try
{
using (StreamReader sr = new StreamReader(TemplatePath, System.Text.Encoding.Default)) //模板页路径
{
String line;
while ((line = sr.ReadLine()) != null)
{
htmltext.Append(line);
}
sr.Close();
}
return htmltext.ToString();
}
catch(Exception ex)
{
return ""; }
} while ((line = sr.ReadLine()) != null)
{
htmltext.Append(line);
}这一段是读行,但是我现在TXT里是排好版的,如果读到TEXTBOX上就乱乱的,不是TXT里一样了...
所以我想一行一行的读TXT然后一行一行的放到TEXTBOX里,这样就不会乱了...
该怎么改...
解决方案 »
- 正则表达式请教!
- asp.net mvc3 view问题
- C# 数据比较
- C#如何为tabpage设置背景图片?????急啊!!!!!!!!!!!!!!!!!!
- 下列C#代码怎么写注册机?谁帮我写下
- 关于OleDbDataAdapter 对象一问
- 请教c#中的类和java中的类有什么区别和联系,数据库连接一般都写在哪呀,是建一个connection类吗?
- 参数传递问题
- EnumChildWindows 在查找多选项卡内的子窗体时会出错,有没有高手知道原因的?
- 求PPC上写无边框TEXTBOX控件的方法。
- 电子商务网站的电子文档的帮助服务等信息的处理
- 对一个类进行系列化后,能不能按这个类的一个字段进行排序?
你要想换行,那就htmltext.Append(line+"\r\n");
while ((line = sr.ReadToEnd()) != null)
{
htmltext.Append(line);
}
richTextBox1.AppendText(str);
跟txt里边的格式一样的
{
//---------------------读html模板页面到stringbuilder对象里----
try
{
using (StreamReader sr = new StreamReader(TemplatePath, System.Text.Encoding.Default)) //模板页路径
string str = sr.ReadToEnd();
return str;
}
catch(Exception ex)
{
return ""; }
}
这样就行了啊