How to work with time (C#)?

I have a startup form, this code works
private void Form1_Load(object sender, EventArgs e)
{
 StreamWriter sw = new StreamWriter(@"c:\windows\file.txt", true);
sw.WriteLine("izi");
sw.Close();
 }

How to make in 20 minutes happened removing "easy" from file.txt?
(Line number is not know)
March 19th 20 at 08:54
1 answer
March 19th 20 at 08:56
Solution
There is little data.

1) What will happen if the file is.
2) What will happen if the disk runs out place?
3) What happens if the program closes, and no 20 minutes may not be out of the question?
4) Which line to remove if there's thousands of them the same?
5) What will happen if after 20 minutes the file will not be on the disk?

To delete a file by the same process that created it/updated it should work more than 20 minutes.
If this is not possible, you need to create another program that in 20 minutes will remove from it the desired text. And run it goboy.

If you talk about the problem for yourself, then you can just use a Timer.
In C# 4 types of timers on the link above they are described.
System.Timers.Timer
System.Threading.Timer
System.Windows.Forms.Timer
System.Web.UI.Timer
System.Timers.Timer
System.Threading.Timer

It's the same timer under different wrappers. - Valentina34 commented on March 19th 20 at 08:59

Find more questions by tags C#