One of my clients wanted a way to interact with local files (open folders, launch the associated application) from a web page. In this way, they could construct home page for the user and link to “local files” the same way as if they were on the internet.
This worked using IE (not Chrome nor Edge) through the file protocol. You could effectively do this :
<a href="file://t:\data">Data directory</a> <a href="file://t:\data\file.txt">text file</a>
And the web page (on IE) would render two links, which would either open the folder in explorer or the file in notepad.
How would you fix this problem with Chrome and Edge ?
What we have prototyped is the creation of a UWP app that registers two URL protocols. Then you simply use these protocols in your web page and the UWP app will handle the request and do something, effectively bridging the gap between web and desktop…
Here is the updated HTML:
<a href=”myAppOpenFolder://t:\data”>Data directory</a>
<a href=”myAppOpenFile://t:\data\file.txt”>text file</a>
Once that is done, you need to create a new UWP app and register your new protocol declarations in the manifest, it should look like this:
<Extensions> <uap:Extension Category="windows.protocol"> <uap:Protocol Name="myAppOpenFolder"> <uap:DisplayName>myAppOpenFolder</uap:DisplayName> </uap:Protocol> </uap:Extension> <uap:Extension Category="windows.protocol"> <uap:Protocol Name="myAppOpenFile"> <uap:DisplayName>myAppOpenFile</uap:DisplayName> </uap:Protocol> </uap:Extension> </Extensions> </Application> </Applications>
Once the manifest is done, you simply handle the situation in you app.cs:
protected override void OnActivated(IActivatedEventArgs e)
if (e.Kind == ActivationKind.Protocol)
var protocolArgs = e as ProtocolActivatedEventArgs;
if (protocolArgs.Uri.Scheme == “myAppOpenFolder”)
else if (protocolArgs.Uri.Scheme == “myAppOpenFile”)