文本操作

    public void BindData()
    {
        string path1 = Server.MapPath("../txt/comm.txt");
        FileStream file1 = File.Open(path1, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
        StreamReader read = new StreamReader(file1, Encoding.GetEncoding("GB2312"));
        this.FCKeditor1.Value = read.ReadToEnd().ToString();
        read.Close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string path = Server.MapPath("../txt/comm.txt");
        FileStream file = File.Open(path, FileMode.Truncate, FileAccess.ReadWrite, FileShare.ReadWrite);
        StreamWriter stream = new StreamWriter(file, Encoding.GetEncoding("GB2312"));
        string content = this.FCKeditor1.Value;
        stream.Write(content);
        stream.Flush();
        stream.Close();
    }

posted @ 2008-11-03 18:41  余魁  阅读(155)  评论(0编辑  收藏  举报