private void button1_Click_1(object sender, EventArgs e) { h1 = h;//hours m1 = m;//minutes s1 = s;//seconds //booleano is my boolean value that starts in true //MessageBox.Show(""+booleano); if (booleano) { foreach (String st in tokens1) { time = tokens1[0] + "," + tokens1[1] + "," + tokens1[2] + "," + h1 + "," + m1 + "," + s1 + "," + false.ToString() + "," + true.ToString(); } System.IO.File.WriteAllText(Application.StartupPath + "\\time.txt", time); //MessageBox.Show(Application.StartupPath); st.wYear = short.Parse(""+2014); // must be short st.wMonth = short.Parse(""+1); st.wDay = short.Parse(""+1); SetSystemTime(ref st); booleano = false; } else { booleano = true; FileStream file = new FileStream(Application.StartupPath+"\\time.txt", FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(file); sr.ReadLine(); var textLines = File.ReadAllLines(Application.StartupPath + "\\time.txt"); foreach (var line in textLines) { string[] dataArray = line.Split(','); st.wYear= short.Parse(dataArray[0]); st.wMonth = short.Parse(dataArray[1]); st.wDay = short.Parse(dataArray[2]); st.wHour = short.Parse(dataArray[3]); st.wMinute = short.Parse(dataArray[4]); st.wSecond = short.Parse(dataArray[5]); } file.Close(); SetSystemTime(ref st); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)