var lines2 = File.ReadAllLines("file.path");
File.WriteAllLines("file.path", lines2.Take(lines2.Length - 2).ToArray());
using (StreamWriter db = new FileInfo("file.path").AppendText())
db.Writeline("");
This is my code to delete the last two lines and write after into a new line my text, this works fine,
but, i need the same to delete the last 2 characters into the last line (text file has only one line) and add to the same line without space or new line, my text.
I tried several times but failed. Also google could not help me.
Example:
text before: Hello, that's an example!!
delete last two characters: Hello, that's an example
add to text: ???
text after: Hello, that's an example???
i want to delete the last two characters !! and add whatever i want behind the last word