初学c#,大家帮帮忙!
目的简单,就是点一个button,往txt里添加一条记录。可是,下面的程序怎么一直是覆盖记录啊……
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        
        
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
            try
            {                FileStream aFile = new FileStream(@"D:\银行.txt", FileMode.OpenOrCreate);                StreamWriter sw = new StreamWriter(aFile);
                sw.WriteLine(textBox1.Text);
                textBox1.Text = null;
                               sw.Close();            }            catch (IOException e)
            {                Console.WriteLine("An IO exception has been thrown!");                Console.WriteLine(e.ToString());                Console.ReadLine();                return;            }
        }
    }
}

解决方案 »

  1.   

       sw.WriteLine(textBox1.Text,true); 
      

  2.   

    StreamWriter sw = File.AppendText(Server.MapPath(".")+"\\A.txt"); 
    sw.WriteLine("AAA"); 
    sw.WriteLine("BBB"); 
    sw.Flush(); 
    sw.Close(); 
      

  3.   

    默认就是ture吧,无效,还是没有添加,只是覆盖啊
      

  4.   

    using (StreamWriter sw = File.CreateText(@"D:\银行.txt", )) 
                {
                   sw.WriteLine(textBox1.Text); 
                }
      

  5.   

    错了是using (StreamWriter sw = File.AppenText(@"D:\银行.txt", )) 
                { 
                  sw.WriteLine(textBox1.Text); 
                }