I am working on a visual studio project in which I have a webpage I would like to display in webbrowser. Currently I have a folder named resources in which I have copied all the required html,js and css files, but I don't know how to point it in the project. Any ideas? Thank you.
Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
string appPath = Assembly.GetEntryAssembly().Location;
string filename = Path.Combine(Path.GetDirectoryName(appPath), "resources\\index.html");
notes.Navigate(filename);
}
}
}
Thank you.
Update
I have pasted the contents of the resources folder directly in the project, and tried multiple options suggested in the URL. Unfortunately, nothing is working, and I am new to Visual studio, so don't even have an idea what's going wrong. Updated code :
private void Form1_Load(object sender, EventArgs e)
{
//string curDir = Directory.GetCurrentDirectory();
//this.notes.Url = new Uri(String.Format("file:///resources/index.html", curDir));
string applicationDirectory = Path.GetDirectoryName(Application.ExecutablePath);
string myFile = Path.Combine(applicationDirectory, "index.html");
notes.Url = new Uri("file:///" + myFile);
}