السلام عليكم
هذه طريقة قراءة ملف ونسخه في ملف جديد ثم حذف الملف القديم
اتمنى ان تفيدكم :)
System.IO.FileInfo F = new System.IO.FileInfo(@"C:\a.txt");
System.IO.StreamReader SR = F.OpenText();
System.IO.StreamWriter SW = new System.IO.StreamWriter(@"C:\a1.txt",true);
string txt = null;
do
{
txt = SR.ReadLine();
SW.WriteLine(txt);
} while (txt != null);
SR.Close ();
SW.Close();
F.Delete();