TEXTBOX.NAME=tyazi
DOSYADAN OKU.NAME=doku
DOSYADAN YAZ.NAME=dyaz
//www.mehmetakiftezcan.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
//www.mehmetakiftezcan.com
namespace ornek2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dyaz_Click(object sender, EventArgs e)
{
DialogResult basilanbutton;
basilanbutton = saveFileDialog1.ShowDialog();
if (basilanbutton == DialogResult.OK)
{
if (File.Exists(Path.GetFullPath(saveFileDialog1.FileName))) //DOSYA VARMI YOKMU KONTROL EDER
{
try
{
sayac = 0;
label1.Visible = false;
label1.Text = "Dosya Yazıldı!";
File.WriteAllText(Path.GetFullPath(saveFileDialog1.FileName), tyazi.Text); //tyazinin içindeki bilgiler dosyaya yazılıyor..
label1.Visible = true;
timer1.Enabled = true;
}
catch {
MessageBox.Show("Dosya Yazılamadı");
}
}
}
}
private void doku_Click(object sender, EventArgs e)
{
DialogResult basilanbutton;
basilanbutton = openFileDialog1.ShowDialog();
if (basilanbutton == DialogResult.OK)
{
if (File.Exists(Path.GetFullPath(openFileDialog1.FileName)))
{
try
{
sayac = 0;
label1.Visible = false;
label1.Text = "Dosya Okundu!";
String[] veriler = new String[] { }; //Dosyanın içindeki veriler veriler dizisine eklenecek
veriler = File.ReadAllLines(Path.GetFullPath(openFileDialog1.FileName));
string metin = "";
/* Alternatif olarak Dosyanın içindeki veriler foreach komutu ile diziye okunabilir
foreach (string line in veriler)
{
if (metin.Length > 0) metin += ";";
metin += line;
*/
metin = String.Join(";", veriler);//dosyadaki her satır ; den önceki ve sonraki diye ayrılıyor
tyazi.Text = metin;
//Alternatif olarak satırlar böylede okunabilir
/*StreamReader sr = new StreamReader(Path.GetFullPath(openFileDialog1.FileName));
string veriler1 = sr.ReadLine();
string veriler2 = sr.ReadLine();
string veriler3 = sr.ReadLine();
sr.Close();
tyazi.Text = veriler1+";;"+veriler2+";;"+veriler3;*/
label1.Visible = true;
timer1.Enabled = true;
}
catch
{
MessageBox.Show("Dosya Okunamadı");
}
}
}
//www.mehmetakiftezcan.com
}
private void Form1_Load(object sender, EventArgs e)
{
openFileDialog1.FileName = "dosya";
openFileDialog1.Filter = "Text Dosyaları(.txt)|*.txt||*.mp4";
openFileDialog1.InitialDirectory = "";
openFileDialog1.Title = "Okunacak Text Dosyasını Seçin";
saveFileDialog1.Title = "Kaydedilecek Dosyayı Seçin";
saveFileDialog1.FileName = "dosya";
saveFileDialog1.Filter = "Text Dosyaları(.txt)|*.txt";
label1.Text = "";
}
int sayac = 0;
private void timer1_Tick(object sender, EventArgs e)
{
sayac++;
if (sayac < 15)
{
if (sayac % 2 == 1)
label1.Visible = true;
else
label1.Visible = false;
}
else
{
timer1.Enabled = false;
label1.Visible = false;
}
}
}
}
//www.mehmetakiftezcan.com
0 yorum:
Yorum Gönder
yorum yaz