2 Kasım 2014 Pazar

02. Text Dosyasına Veri Yazan Sınıf

Exported from Notepad++
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading.Tasks; namespace DosyayaYazdirmaLib { public class DosyayaYaz { string yol; public string Yol { get { return yol; } set { yol = value; } } string mesaj; public string Mesaj { get { return mesaj; } set { mesaj = value; } } public FileMode DosyaModu() { return File.Exists(this.Yol) ? FileMode.Append : FileMode.OpenOrCreate; //deger ? doğruysa : yanlışsa ; } public void MesajYaz() { FileStream yer = new FileStream(this.Yol, DosyaModu()); StreamWriter yazacak = new StreamWriter(yer); yazacak.WriteLine(this.Mesaj); yer.Flush(); yazacak.Close(); yer.Close(); Console.WriteLine(this.Yol+"\n\n"+this.Mesaj +"\n\nKayıt tamamlandı."); } } }

Hiç yorum yok:

Yorum Gönder