With a small number of lines, you could easily use something like this
string filename = @"C:\Temp\junk.txt";
string[] lines = File.ReadAllLines(filename);
File.WriteAllLines(filename, lines.Take(lines.Count() - 1));
However, as the files get larger, you may want to stream the data in and out with something like this
string filename = @"C:\Temp\junk.txt";
string tempfile = @"C:\Temp\junk_temp.txt";
using (StreamReader reader = new StreamReader(filename))
{
using (StreamWriter writer = new StreamWriter(tempfile))
{
string line = reader.ReadLine();
while (!reader.EndOfStream)
{
writer.WriteLine(line);
line = reader.ReadLine();
} // by reading ahead, will not write last line to file
}
}
File.Delete(filename);
File.Move(tempfile, filename);