ASP.net(C#) 我中的一个Textbox1 怎么能让它读文本是中文?
还有文本中是1段格式的文章到Textbox1中就变成1行了 该怎么改?
private void Page_Load(object sender, System.EventArgs e)
{
StreamReader sreader;
string Sstring="";
string file=Server.MapPath("file1.txt");
sreader=File.OpenText(file);
while(sreader.Peek()!=-1)
{
Sstring=sreader.ReadLine();
TextBox1.Text+=Sstring;
}
sreader.Close();
}
还有文本中是1段格式的文章到Textbox1中就变成1行了 该怎么改?
private void Page_Load(object sender, System.EventArgs e)
{
StreamReader sreader;
string Sstring="";
string file=Server.MapPath("file1.txt");
sreader=File.OpenText(file);
while(sreader.Peek()!=-1)
{
Sstring=sreader.ReadLine();
TextBox1.Text+=Sstring;
}
sreader.Close();
}
{
StreamReader sreader;
string Sstring="";
string file=Server.MapPath("file1.txt");
//sreader=File.OpenText(file);
sreader=new StreamReader(file,System.Text.Encoding.GetEncoding ("GB2312"));
while(sreader.Peek()!=-1)
{
Sstring=sreader.ReadLine();
TextBox1.Text+=Sstring;
}
sreader.Close();
}
VB是:Textbox1.Text=contents.Replace(vbCrLf,"<br>")可以实现
C#的怎么把读入的是一段有格式的文章放入到文本域里呢?
{
StreamReader sreader;
string Sstring="";
string file=Server.MapPath("file1.txt");
sreader=new StreamReader(file,System.Text.Encoding.GetEncoding ("GB2312"));
while(sreader.Peek()!=-1)
{
Sstring+=sreader.ReadLine();
}
sreader.Close();
TextBox1.Text=Sstring.Replace("\r\n","<br>");
}其中你的TextBox1要是多行的或用rechtextbox等