Csharp Txt yazma okuma
2 TextBox daha fazlada olur.
1 Adet ListBox

Button ekliyelim.

Button  txt_OluÅŸtur Click

try
{
StreamReader STR=File.OpenText("C:\\txtOlustur");//Var ise Açıyoruz
STR.Close()
}
Catch
{
StreamWriter STW=File.CreateText("C:\\txtOlustur"); //Yok ise yeni oluÅŸturuyoruz
}

Button Txt_Kaydet Click

StreamWriter STW=File.AppendText("C:\\txtOlustur");// Metin yazacağımız dosyayı seçiyoruz
STW.WriteLine(TextBox1.Text+ Environment.NewLine+TextBox2.Text);//yan yana yazmak için \t kullanabilirsiniz alt alta geçmesini isterseniz Environment.NewLine;


Button Txt_Oku Click

StreamReader STR=File.OpenText("C:\\txtOlustur");
string Oku=STR.ReadLine();
while(oku!=null)
{
ListBox1.Items.Clear();
ListBox1.Items.Add(Oku);
Oku=STR.ReadLine();
}

Yorumlar

Daha yeni Daha eski