ASP.NET学习社区

首页 » ASP.NET学习区 » 自由问答 » response对象的writefile方法出现的问题?
love.money - 2008-5-12 9:06:00
我的源文件:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>response对象的writefile事件</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        </div>
    </form>
</body>
</html>

我的代码文件:
protected void Page_Load(object sender, EventArgs e)
    {
        Response.Charset = "GB2312";
        Response.WriteFile("File.txt");
    }

显示出来的结果就是源文件中的中文是乱码!
如果把Response.Charset = "GB2312";注释掉,那从文件中读出的中文内容就是乱码!
为什么啊?请高手指教!
asp.net - 2008-5-12 9:22:00
文件编码的问题了。
先看看file.txt的编码是什么,然后将Response.Charset  , Response.ContentEncoding  , Response.HeaderEncoding 等的编码设置成一致,试试。
love.money - 2008-5-12 10:02:00
file.txt就是一文本文件,不知道怎么查看它的编码??
1
查看完整版本: response对象的writefile方法出现的问题?