SIDEBAR
»
S
I
D
E
B
A
R
«

Buton Tıklatma
Haz 20th, 2011 by Özcan BAYĞUŞ

button2_Click(sender,new EventArgs());

Buton 2 yi tıklar.

 

Csharp dosyadan okuma ve yazma örneği
Oca 14th, 2010 by Özcan BAYĞUŞ

Forma openDialog ekleyin. using e using System.IO; ekliyoruz. Butona aşağıdaki kodu yazıyoruz. Seçtiğimi txt dosyasının satırların başına ve sonuna , virgül eklemeye yarıyor. Değişikliği C: sürücüsüne csharp.txt adında kayıt ediyor.

            string satir;
            FileStream fs,fw;
            StreamReader sr;
            StreamWriter sw;
            string dosya_adi;
            DialogResult c = openFileDialog1.ShowDialog();
            if (c == DialogResult.OK)
            {
                dosya_adi = openFileDialog1.FileName;
                fs = new FileStream(dosya_adi, FileMode.Open, FileAccess.Read);
                fw = new FileStream("c:\\Csharp.txt", FileMode.OpenOrCreate, FileAccess.Write);
                sr = new StreamReader(fs);
                sw = new StreamWriter(fw);
                while ((satir = sr.ReadLine()) != null)
                {
                    sw.WriteLine(","+satir+",");
                }
                sw.Close();
                sr.Close();
                fw.Close();
                fs.Close();

            }

»  Substance:WordPress   »  Style:Ahren Ahimsa