Click here to Skip to main content
15,614,257 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi The code below supposed to display html file content in a webrowser locally according to
present day i.e if the user open the app on 25/2/2016 the app should open devotion56.html which is the
56th day of the year. I have all 366 html files in a folder (Devotion). But when i test the app in a device
it does not load the content but shows error page on the browser
See my code below

namespace HtmlWebViewLocally
public partial class PivotHtmlLocally : PhoneApplicationPage
public PivotHtmlLocally()

var dttimne = DateTime.Now;
string date = dttimne.Day.ToString();
string month = dttimne.Month.ToString();
string year = dttimne.Year.ToString();
string htmlfilename = date + "_" + month + "_" + year;
string FinalHtmlName = "Devotion/" + htmlfilename + ".html";

SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
//This is the navigate uri of all the 366 html files of each day
webBrowser1.Navigate(new Uri("Devotion/devotion1.html", UriKind.Relative));
webBrowser1.Navigate(new Uri("Devotion/devotion2.html", UriKind.Relative));
webBrowser1.Navigate(new Uri("Devotion/devotion3.html", UriKind.Relative));
webBrowser1.Navigate(new Uri("Devotion/devotion4.html", UriKind.Relative));
webBrowser1.Navigate(new Uri("Devotion/devotion5.html", UriKind.Relative));
Kindly help

What I have tried:

I have tried asking on windows phone forum but not clear with the answer given
Updated 29-Feb-16 1:12am

1 solution

As far as I can see, you're creating file names Devotion_29_02_2016.html for today.
I don't see you calculating which day in the year current day is. Use DateTime methods for that:
DateTime Structure (System)[^]

In your particular case:

var dttimne = DateTime.Now;
string FinalHtmlName = String.Format("Devotion{0}.html", dttimne.DateOfYear);

Please accept the solution if it solves your problem and good luck.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900