StreamReader 读取文件自动换行

http://hi.baidu.com/liulin0712/blog/item/5dae58d02ecd7789a1ec9c3b.html

 

 

StringBuilder htmltext = new StringBuilder();
                string newsTemp = HttpContext.Current.Server.MapPath(indextempath);
                //Encoding code = Encoding.GetEncoding("utf-8");
                Encoding code = Encoding.GetEncoding("gb2312");
                try
                {
                    using (StreamReader sr = new StreamReader(newsTemp, code))
                    {
                        String line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            htmltext.Append(line + "\r");
                        }
                        sr.Close();
                        this.neirong.Text =htmltext.ToString();
                    }
                }

你可能感兴趣的:(Stream)