在本地webrowser中显示html文件内容 [英] Display html file content in a webrowser locally
问题描述
嗨
下面的代码应该在当地的webrowser中显示html文件内容,根据
当天,即如果用户在2016年2月25日打开应用程序应该打开devotion56.html这是
一年中的第56天。我在一个文件夹(Devotion)中有所有366个html文件。但是,当我在设备中测试应用程序
时,它不会加载内容但在浏览器上显示错误页面
请参阅下面的代码
名称空间HtmlWebViewLocally
{
公共部分类PivotHtmlLocally:PhoneApplicationPage
{
public PivotHtmlLocally()
{
InitializeComponent();
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;
//这是每天所有366个html文件的导航uri
webBrowser1.Navigate(新的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));
请帮助
< b>我尝试了什么:
我试过在Windows手机论坛上询问但不清楚给出的答案
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()
{
InitializeComponent();
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
推荐答案
据我所知,你今天正在创建文件名Devotion_29_02_2016.html。
我看不到你计算当年哪一天一天是。使用DateTime方法:
DateTime结构(系统) [ ^ ]
在您的特定情况下:
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.
这篇关于在本地webrowser中显示html文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!