i need your help! if my codes runs, Console appears and write datetime.now line by line, but if i open my txt(TextFile1.txt) . i don't see console command results.
console result in black pad
- 22:30 29.01.2010
- 22:31 29.01.2010
- 22:32 29.01.2010
- 22:33 29.01.2010
BUT; on the other hand; if i open textfile (Textfile1.txt), i see only one time result , i want to see whole time result like above.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.IO;
namespace TimerApp4
{
class Program
{
static void Main(string[] args)
{
Timer t = new Timer(1000);
t.Elapsed += new ElapsedEventHandler(SaniyelikIs);
t.Start();
Console.Read();
t.Stop();
}
static void SaniyelikIs(object o, ElapsedEventArgs a)
{
// write a line of text to the file
StreamWriter tw = new StreamWriter("TextFile1.txt");
tw.WriteLine(DateTime.Now);
Console.WriteLine(DateTime.Now + "\n");
// close the stream
tw.Close();
}
}
}