部分代码如下:
==============================================================================
.aspx
==============================================================================
<asp:TextBox ID="txtFileContent" TextMode="MultiLine" BackColor="#dff8ff" Font-Size="9" Font-Name="新宋体" Width="98%" Rows="30" runat="server"/>
==============================================================================
.cs
==============================================================================
string strPath = txtPath.Text;
if(!strPath.StartsWith("/"))
strPath = "/" + strPath;
StreamWriter sw = File.CreateText(Server.MapPath(strPath));
sw.Write(txtFileContent.Text);
sw.Close();
==============================================================================

解决方案 »

  1.   

    StreamReader sr = new StreamReader( filepath,System.Text.Encoding.GetEncoding( 936 ));
      

  2.   

    StreamWriter sw = File.CreateText(Server.MapPath(strPath));
    改为
    StreamWriter sw = new  StreamWriter(File.CreateText(Server.MapPath(strPath),Encoding.GetEncoding("GB18030"));
      

  3.   

    StreamWriter sw = new  StreamWriter(File.CreateText(Server.MapPath(strPath)) ,Encoding.GetEncoding("GB18030"));
      

  4.   

    我读取的时候就已经使用了:StreamReader sr = new StreamReader(File.Open(Server.MapPath(strPath),FileMode.Open),System.Text.Encoding.GetEncoding("GB2312"));
    txtFileContent.Text = sr.ReadToEnd();
    sr.Close();
      

  5.   

    Encoding.GetEncoding("GB18030")
    这个
      

  6.   

    完全同意welshem(天堂客) 的说法
      

  7.   

    编译器错误信息: CS1501: 重载“CreateText”方法未获取“2”参数源错误: 行 69:  if(!strPath.StartsWith("/"))
    行 70:  strPath = "/" + strPath;
    行 71:  StreamWriter sw = new  StreamWriter(File.CreateText(Server.MapPath(strPath),Encoding.GetEncoding("GB18030")));
    行 72:  sw.Write(txtFileContent.Text);
    行 73:  sw.Close();
     
      

  8.   

    编译器错误信息: CS1502: 与“System.IO.StreamWriter.StreamWriter(System.IO.Stream, System.Text.Encoding)”最匹配的重载方法具有一些无效参数源错误: 行 69:  if(!strPath.StartsWith("/"))
    行 70:  strPath = "/" + strPath;
    行 71:  StreamWriter sw = new  StreamWriter(File.CreateText(Server.MapPath(strPath)),System.Text.Encoding.GetEncoding("GB18030"));
    行 72:  sw.Write(txtFileContent.Text);
    行 73:  sw.Close();