How do i create a file which can store the output info? for example, i need to get a output where the name repeats 10000 times.. once i stop running the program and start again, it should display the new outputs with the values of the old one.. And if i stop it in between, say 4000th time, it shud start again from 4001 and not all over again.. and how do i use file in this program? could someone help me with the entire program?
The program is –
namespace Time_Writer
{
class Program
{
static int count = 1;
static double seconds;
private static System.Timers.Timer aTimer;
static void Main(string[] args)
{
aTimer = new System.Timers.Timer();
aTimer.Elapsed +=new System.Timers.ElapsedEventHandler(aTimer_Elapsed);
aTimer.Interval = 5000;
aTimer.Enabled = true;
Console.WriteLine("Press Enter To Exit The Program\n");
Console.ReadLine();
}
private static void aTimer_Elapsed(object source, ElapsedEventArgs e)
{
Console.WriteLine("Name is Yap {0}", e.SignalTime);
seconds += 5;
count += 1;
if (count>10)
{
aTimer.Enabled = false;
Console.WriteLine("\n\nTimer is off at {0}\n\n", e.SignalTime.TimeOfDay.ToString());
}
}
}
}
In this example I just save the bits of the count variable to a file in the same directory.