السلام عليكم ورحمة الله وبركاته
كود بسيط حبيت اقدمه
المستوي : متوسط
سوف نقوم بالكتابه في RichTextBox وحفظ هذه الكتابة في ملف خارجي بامتداد moh
ال Namespace :
using System.IO;
كود ال Save:
string StringToSave = MyRichTextBox.Text;
SaveFileDialog MySaveDialog = new SaveFileDialog();
MySaveDialog.Filter = ".moh (*.moh)|*.moh";
if (MySaveDialog.ShowDialog == DialogResult.OK) {
string Path = MySaveDialog.FileName;
FileStream MyFileStream = new FileStream(Path, FileMode.Create);
StreamWriter MyWriter = new StreamWriter(MyFileStream);
MyWriter.Write(StringToSave);
MyWriter.Close();
MessageBox.Show("Saved");
}كود ال Open :
OpenFileDialog MyOpenDialog = new OpenFileDialog();
MyOpenDialog.Filter = ".moh (*.moh)|*.moh";
if (MyOpenDialog.ShowDialog == DialogResult.OK) {
string Path = MyOpenDialog.FileName;
StreamReader MyReader = new StreamReader(Path, System.Text.Encoding.Default);
MyRichTextBox.Text = MyReader.ReadToEnd;
}المثال في المرفقات
Have fun ;) ;)