Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             timer1.Start();
  4.             timer1.Interval = 1000;
  5.            
  6.             //easier, so you don't have to retype it and make typos
  7.             string fileName = @"C:\Users\Kim Le\Dropbox\HTX - Portfolio\Programering\Edit\KimLe2HTXEksame\KimLe2HTXEksame\data\data.txt";
  8.            
  9.             //if file exists, load it, if not, there is no data saved
  10.             if (File.Exists(fileName))
  11.             {
  12.                 //read all the lines in the file
  13.                 string[] lines = System.IO.File.ReadAllLines(fileName);
  14.                 //for each line in the file
  15.                 for (int i = 0 ; i < lines.Length ; i++)
  16.                 {
  17.                     //convert the string to a date
  18.                     DateTime dt = Convert.ToDateTime(lines[i]);
  19.                     //put the date in your list
  20.                     Organiseret.Add(dt);
  21.                 }
  22.             }
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement