public partial class MainPage : PhoneApplicationPage { List<string> devotions = new List<string>(); // Constructor public MainPage() { InitializeComponent(); AddDevotions(); int index = DateTime.Now.DayOfYear; textblock.Text = devotions[index]; // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); } protected override void OnNavigatedTo(NavigationEventArgs e) { DateTime dt = DateTime.Now; int month = dt.Month; int year = dt.Year; int index; if (DateTime.IsLeapYear(year) || (month <= 2)) { index = dt.DayOfYear - 1; // list is indexed from 0 } else { index = dt.DayOfYear; // add a day } textblock.Text = devotions[index].ToString(); // or some other property } private void AddDevotions() { for (int i = 1; i <= 366; i++) { string filePath = Path.GetFullPath("Devotions/Devotion1" + i.ToString() + ".txt"); if (File.Exists(filePath)) { devotions.Add(ReadTextFile(filePath)); } else { devotions.Add(string.Format("Devotions file '{0}' was not found.", i)); } } } public string ReadTextFile(string textFilePath) { string text = null; using (StreamReader r = new StreamReader(textFilePath)) { text = r.ReadToEnd(); } return text; }
string filePath = Path.GetFullPath("Devotions/Devotion1" + i.ToString() + ".txt");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)