title: C# How to delete last 2 characters from text file and write into the same line at the end my text?
body: <pre><code>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("");
  </code></pre>
  
  <p>This is my code to delete the last two lines and write after into a new line my text, this works fine, </p>
  
  <p>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.</p>
  
  <p>I tried several times but failed. Also google could not help me. </p>
  
  <p>Example:</p>
  
  <p>text before: Hello, that's an example!!</p>
  
  <p>delete last two characters: Hello, that's an example</p>
  
  <p>add to text: ???</p>
  
  <p>text after: Hello, that's an example???</p>
  
  <p>i want to delete the last two characters !! and add whatever i want behind the last word</p>