I agree with John Saunders, this isn't really C# specific. However, to answer your question: you basically need to rewrite the file. There are two ways you can do this.
File.ReadAllLines
)List<string>
then remove the line)File.WriteAllLines
) - potentially convert the List<string>
into a string array again using ToArray
That means you have to know that you've got enough memory though. An alternative:
TextReader
/TextWriter
, e.g. with File.OpenText
and File.CreateText
)TextReader.ReadLine
) - if you don't want to delete it, write it to the output file (TextWriter.WriteLine
)using
statements for both, this will happen automatically)