-1-
-2-
التعامل مع الملفات النصية فى سى شارب
Dealing with text files CSharp
====================قائمة الملفات
===================
كورس Windows Desktop Applications in c sharp مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98yVy2t1hE3t4t1zKAxAvpkW
==========
قائمة الملفات
===================
تعلم لغة c sharp من البداية الى الاحتراف مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98xzr_x2vafMGx9_gCIkZhM6
======================
قائمة الملفات
===============
كورس Object-oriented programming C Sharp مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98yRqBvoBB2Wi3mNro5DDdOL
=======================
قائمة الملفات
===============
Database Analysis and design Full course - ERD schema مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98zl-h_NvnQAs8BW8QRMIw-P
======================
قائمة الملفات
===============
تعلم باحتراف MS SQL server 2019 مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98zuTzQXSZYomkE-RLntASLB
=================
الموقع
https://course-7.blogspot.com/
=============================
الكود كامل
===================================
===================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace wfa0008
{
public partial class Form1 : Form
{
private object directory;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//==============================
StreamWriter sw = new StreamWriter("mydata.txt"); //== new
StreamWriter sw1 = new StreamWriter("mydata1.txt",true); //==append
StreamWriter sw2 = new StreamWriter("mydata2.txt", true, Encoding.Unicode); //==append
//==============================
sw.Write("hhhhhh");
sw.Write("fghfghfg");
sw.WriteLine("============line1");
sw.WriteLine("===============================line2");
sw.WriteLine("===========================================line3");
sw.Close();
//==============================
//==============================
sw1.Write("hhhhhh");
sw1.Write("fghfghfg");
sw1.WriteLine("============line1");
sw1.WriteLine("===============================line2");
sw1.WriteLine("===========================================line3");
sw1.Close();
//==============================
//==============================
sw2.WriteLine("مهندس ");
sw2.WriteLine("بديع");
sw2.WriteLine(" برمجة سى شارب");
sw2.Close();
//==============================
}
private void button3_Click(object sender, EventArgs e)
{
Directory.CreateDirectory("mydir");
Directory.CreateDirectory("mydir1");
Directory.CreateDirectory("d:\\cc\\dd\\mydir1");
}
private void button4_Click(object sender, EventArgs e)
{
Directory.Delete("mydir1");
}
private void button5_Click(object sender, EventArgs e)
{
//=== delete file
File.Delete("mydata.txt");
}
private void button2_Click(object sender, EventArgs e)
{
StreamReader sr = new StreamReader("mydata2.txt");
string rline;
int x = 1;
do
{
rline = sr.ReadLine();
textBox1.Text += rline+" "+x.ToString()+ "\r\n";
x++;
} while (rline !=null);
}
private void button6_Click(object sender, EventArgs e)
{
StreamReader sr = new StreamReader("mydata2.txt");
string rAlllines = sr.ReadToEnd();
textBox1.Text = rAlllines;
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
}
}
=======================
الكود فى ملف خارجى يمكن نسخة بسهولة
-3-
-4-