NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

namespace IO_giriscikisIslemleri
{/*
Dosya okuma yazma işlemleri
System.IO kütüphanesinde bulunur.

FileMode Enumaration
Açıklama
Create: FileMode.Create seçeneği ile yeni bir dosya oluşturulur. Aynı dosya varsa üzerine yazılır.
CreateNew: Yeni bir doys oluşturulur, eğer aynı dosya varsa IOException hatası alınır.
Append: Dosya açılarak sonundan başlayarak yazma işlemi yapılır. Eğer dosya yoksa oluşturulur.

FileMode.Appened seçeneği sadece FileAccess.Write seçeneği ile kullanılır diğer kullanımlarda ArgumentException hatası alınır.

Open: Dosya belirtilen dizinde varsa açılır.Eğer dosya yoksa FileNotFoundException hatası alınır.
OpenOrCreate: Dosya belirtilen dizinde varsa açılır yoksa oluşturulur.
Trumcate: Dosya açılır ve içerisi boşaltılıp boyutu 0 byte olarak güncellenir.

FileAccess Enumaration Değerleri FileShare: Değerleri olarak sadece None: İşlem yaptığımız kanaldan erişim olur. Diğer kanallardan erişim sağlanamaz. Geri kalan tüm özellikler FileAccess ile aynıdır.

Read: Dosyaya sadece okuma yetkisi verir
Write: Dosyaya sadece yazma erişimi verir
ReadWrite: Hem okuma hem yazma yetkisi verir.
Delete : Silme


File okuma seçenekleri

ReadAllLines: Tüm metni satır satır okur
ReadAllText: Satır bilgisi olmadan tüm satırları okur daha sonra da dosyayı kapatır.// dosyanın tamamını okur sonra da streamı kapatır
ReadAllBytes: dat dosyaları açar byte dizielre aktarır sonra da kapatır.
*/
//dosya okuma yazma işlemlerinde ilgili ananıznızda temasa geşilen durumda oluşturulan bir tünel yapısı var .
class Yaz
{
public int satirsayisi { get; set; }
public void DosyaYaz(string dosyayolu, DateTime tarih, string baslik, string mesaj)
{
//tüm satırları okuma
int satirsayisi = File.ReadAllLines(dosyayolu).Length + 1;

FileStream yaz = new FileStream(dosyayolu, FileMode.Append);//yapıcı metod


using (StreamWriter stream = new StreamWriter(yaz))
{
stream.Write(satirsayisi + "");
stream.Write("t" + DateTime.Now);
stream.Write("t" + baslik);
stream.Write("t" + mesaj);
}
}
}
class Listele
{
public Listele(string dosya_yolu)
{
using (StreamReader reader = new StreamReader(dosya_yolu))
{
string dokuman = reader.ReadToEnd().ToString();
Console.WriteLine(dokuman);
}
}
~Listele()
{
Yaz yaz = new Yaz();
Console.WriteLine(yaz.satirsayisi + "satır listelendi");
}
}
class guncelle
{
}
class Sil
{
}
class Program
{
static void Main(string[] args)
{
string dosya_yolu = @"D:Volkan KayaVS8012019_IO_GirisCikisIslemleri8012019_IO_GirisCikisIslemleriKayitlar.txt";
string secim;
ConsoleKeyInfo info;
do
{
Console.Clear();
Console.WriteLine("****************************");
Console.WriteLine("Günlük Programı");
Console.WriteLine("1. Kayıt Ekleme");
Console.WriteLine("2. Kayıt Listeleme");
Console.WriteLine("3. Kayıt Güncelleme");
Console.WriteLine("4. Kayıt Silme");
Console.WriteLine("5. Çıkış");
Console.WriteLine("****************************");
Console.Write("Seçiniz --> ");
int islem = int.Parse(Console.ReadLine());
switch (islem)
{
case 1:
DateTime tarih = DateTime.Now.Date;
Console.WriteLine("Kayıt Tarihi : " + DateTime.Now.Date.ToLongDateString());
Console.Write("Başlık Giriniz : ");
string _baslik = Console.ReadLine();
Console.Write("Mesajı giriniz : ");
string _mesaj = Console.ReadLine();
Yaz yaz = new Yaz();
yaz.DosyaYaz(dosya_yolu, tarih, _baslik, _mesaj + "n");
#warning buraya yaz metodu eklenecek
break;
case 2: //listeleme
Console.WriteLine("Günlükteki kayıtlar");
Console.WriteLine("NotTarihtBaşlıktMesaj");
Listele listele = new Listele(dosya_yolu);
break;
case 3://Güncelleme
#warning Güncelleme eklenecek
break;
case 4://Silme
#warning Silme eklenecek
break;
case 5://Çıkış
Environment.Exit(1);
string processName = "IO-giriscikisIslemleri"; // Aranan exe
Process[] processes = Process.GetProcesses();//Tüm programları listele (görev yöneticisi)
foreach (Process process in processes)
{
if (process.ProcessName == processName)
{
process.Kill();//Ram'de sonlandırma
}
}
break;
default:
Console.WriteLine("Yanlış seçim yaptınız !");
break;
}
info = Console.ReadKey(true);

if (ConsoleKey.Escape == info.Key)
{
break;
}
} while (info.Key != ConsoleKey.Escape);

}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.