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
        {


        }

    }

你可能感兴趣的:(Stream)