StreamReader & StreamWriter

 public void wirte()
    {
        try
        {
            StreamReader sr = new StreamReader("c:\\Variables.txt");
            string content = sr.ReadToEnd();
            sr.Close();

            StreamWriter sw = new StreamWriter("c:\\Variables.txt", false, Encoding.Unicode);
            string NextLine = "This is the appended line.";

            sw.Write(content + ControlChars.NewLine + NextLine);
            sw.Close();
        }
        catch(Exception ex)
        {
            Response.Write(ex.Message);
        }
        finally
        {


        }

    }

posted on 2008-08-06 21:16  Good life  阅读(280)  评论(0编辑  收藏  举报