欢迎光临
我们一直在努力

C#中生成中文繁体web页面-.NET教程,C#语言

建站超值云服务器,限时71元/月

c#中生成中文繁体web页面

1 在工程中引用microsoft.visualbasic.dll

一般此文件在.net框架环境目录中如c:\ winnt \microsoft.net \framework \v1.1.4322

\microsoft.visualbasic.dll。

2 使用方法

microsoft.visualbasic.strings.strconv( “instr”,microsoft.visualbasic.vbstrconv.traditionalchinese, system.globalization.cultureinfo.currentculture.lcid);

* 该方法的使用可以在msdn中找到。

3 生成web页面使用编码 950,代码如下:

//写文件

public bool writefile( string contentstr,string filepath )

{

try

{

if ( filepath == null)

return false;

this.createdir( filepath.substring( 0,filepath.lastindexof( "\\" ) ) );

streamwriter outstream = new streamwriter( filepath,false,system.text.encoding.getencoding( 950 ) );

outstream.write( contentstr );

outstream.close();

return true;

}

catch

{

return false;

}

}

4 读简体文件时使用编码 936

//读文件

public string readfile( string filepath )

{

string restr = "";

if ( filepath ==null ) return restr;

using ( streamreader sr = new streamreader( filepath,system.text.encoding.getencoding( 936 ) ) )

{

string line;

while( (line = sr.readline())!=null )

{

restr += line+"\r\n";

}

}

return restr;

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » C#中生成中文繁体web页面-.NET教程,C#语言
分享到: 更多 (0)