I wanted to delete 2 last lines of an text file.
I've found this how to delete last line in forum. I get an error of overload of converting string to string[] . After a look I've found this wich advise to use of array. But both does not work with me ?!
Finally I've wrote that
string [] lines = File.ReadAllLines(PublicVariables.AddedFileName);
string [] newlines = new string[lines.Length-2];
for (int i=0; i<lines.Length - 2; ++i)
newlines[i] = lines[i];
File.WriteAllLines(PublicVariables.AddedFileName, newlines);
Why when I use those given exemples don't work with me ? Should I add something ?
I have those as using:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Net.NetworkInformation;
using System.IO;
using System.Threading;
using System.Diagnostics;