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();
                    }
                }

posted @ 2008-12-25 09:58  天涯海客  阅读(376)  评论(0编辑  收藏  举报