Reputation: 23
I made a array out of a txt file and now i want to replace the array in this txt file (replace like in update). becouse i edited the array, and now i want to replace the txt file again , i hope its possible and i hope its possible with breaklines.
string[] linesa = File.ReadLines("file1.txt").ToArray();
this is the line where i make a array of my txt.
number = Array.IndexOf(linesa, commonElement);
number = number + 1;
email = linesa[number];
linesa[number] = "";
number = number - 1;
linesa[number] = "";
this is the edit i made and now i want to put it back in the txt file this is where i have alot of problems with.
Upvotes: 0
Views: 50
Reputation: 101731
Just use WriteAllLines
method. It will replace the contents of the file if the file exists.
File.WriteAllLines("file1.txt", linesa);
Upvotes: 3