i created a button which will create a log file which contain a running number and other info.
the number will increase after each click. this works fine if the application is running and the number log.writeline(i) will increase the number by 1-2-3-4-5...
how do i make the application to detect the last number of the i and continue the number after i re run the application.
current problem is. everytime i restart the application, the loop will start from one again which is not wat i want. i wan it to continue from last number that i had closed.
Int32 i;
#region Functions
private void button2_Click(object sender, EventArgs e)
{
string titletext = "History log ";
i = ++i;
// Create a writer and open the file:
StreamWriter log;
if (!File.Exists("running.log"))
{
log = new StreamWriter("running.log");
log.WriteLine(i);
}
else
{
log = File.AppendText("running.log");
log.WriteLine(i);
}
// Write to the file:
log.WriteLine(titletext + " of " + DateTime.Now);
log.WriteLine("User:" + textBox2.Text);
log.WriteLine("From" + dateTimePicker1);
log.WriteLine("To" + dateTimePicker2);
// Close the stream:
log.Close();

New Topic/Question
Reply



MultiQuote







|