StreamReader sr = new StreamReader(path, Encoding.GetEncode("gb2312")); System.Text.Encoding.Default 或 Encoding.GetEncode("gb2312") 参考: //读取文本文件,注意设置此文件的访问权限 FileStream fs = new FileStream("e:\\通知.txt", FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); strNews = System.Text.Encoding.GetEncoding("gb2312").GetString(bytes); strNews=strNews.Replace("\r","<br/>"); strNews=strNews.Replace("\0"," "); strNews=strNews.Replace("\t"," "); strNews=strNews.Replace(" "," ");
//html 下 <MARQUEE onmouseover="this.stop()" style="BORDER-RIGHT: dimgray thin; BORDER-TOP: dimgray thin solid; Z-INDEX: 101; LEFT: 40px; BORDER-LEFT: dimgray thin; WIDTH: 780px; COLOR: green; BORDER-BOTTOM: dimgray thin solid; POSITION: absolute; TOP: 80px; HEIGHT: 468px; TEXT-DECORATION: none" onmouseout="this.start()" scrollAmount="3" scrollDelay="80" direction="up" behavior="scroll"> <%=strNews%> //读取strNews </MARQUEE>