How can I open a local HTML file in Microsoft Edge browser?

眉间皱痕 提交于 2019-12-02 22:06:58

This is currently not supported, but the team is evaluating it as an option. For the time being, the easiest way to open a resource in Edge is by using the microsoft-edge: protocol handler. For instance, you could run microsoft-edge:http://stackoverflow.com to open Stack Overflow in Edge.

TempGuest

Here is how you can open a PDF for example, with Edge.

Add the following header at the top of your class:

[DllImport("Shell32.dll")]
public static extern int ShellExecuteA(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirecotry, int nShowCmd);

Here is an example of how to make the call.

ShellExecuteA(System.IntPtr.Zero, "open", @"shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge", "C:\MyFile.pdf", null, 10);

I think this will apply fine to other types of files as well.

Herschelle42

Obtain tool from https://github.com/MicrosoftEdge/edge-launcher

MicrosoftEdgeLauncher file:///C:/Users/me/Documents/homepage.html

This works on my system:

create a share and give yourself access

open in Microsoft Edge, as a simple example: file:////bookmark.html

you can get the hostname via the hostname Powershell command among other ways, you can see all the directories you are sharing by using file explorer, opening "network", at your computer and you should see any shares you have established

not necessarily a deeply satisfying answer but works for what I needed.

The following works for local files and also accepts queries (?) and fragments (#) in the URI.

WinAPI / ShellAPI example on a local HTML file:

ShellExecute(
    NULL,
    NULL,
    _T("shell:Appsfolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"),
    _T("file:///c:/temp/test.html?page=1#anchor-1"),
    NULL,
    SW_SHOWNORMAL);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!