Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching Edge with a file URL

The answer to this question shows how to launch Edge with a web URL from C#:

System.Diagnostics.Process.Start("microsoft-edge:http://www.google.com");

However, this doesn't seem to work with file URLs.

System.Diagnostics.Process.Start("microsoft-edge:file:///C:/foo/bar.html");

launches Edge, but the file is not displayed. Instead, Edge opens to its default page. Pasting the same URL ("file:///C:/foo/bar.html") into the Edge address bar works fine, and if I right-click the file in Explorer and choose Open With->Edge, the same URL appears in the address bar.

Does anyone know how to launch Edge with a file URL?

TIA

like image 395
chrisd Avatar asked Aug 26 '18 14:08

chrisd


People also ask

What is the URL for Microsoft Edge start page?

Microsoft Edge Start Page URL : r/MicrosoftEdge.

How do I run an HTML file in Edge?

Locate your html file in file explorer and right click on it > open with > select microsoft edge. Your html will be now open on microsoft edge. You can also set default apps for html files, go to your system settings and search for default apps and select microsoft edge and then in next page for .


2 Answers

As noted in the comments, Edge does not support the file: protocol via the command line at this time.

However, it is currently possible to launch Edge with a local file using IApplicationActivationManager. The necessary code can be extracted from the C# version of MicrosoftEdgeLauncher and integrated into a C# application.

See 'MicrosoftEdgeLauncherCsharp' at https://github.com/MicrosoftEdge/edge-launcher. To launch with a local file, use 'file:///d:/path/filename.ext' as the arguments parameter to ActivateApplication.

like image 71
chrisd Avatar answered Oct 22 '22 16:10

chrisd


One dirty solution: first set your default launcher as Edge.

Suppose the file you want to open is file:///C:/foo/bar.html, you can launch it using explorer:

explorer file:///C:/foo/bar.html

Which will open Edge with the HTML for you. This seems to be the only solution after start microsoft-edge:file:///C:/foo/bar.html no longer works.

like image 37
ice1000 Avatar answered Oct 22 '22 18:10

ice1000