System.Diagnostics.Process not working in Windows

2019-06-02 03:36发布

问题:

I'm working in a UWP app in which I need to launch Microsoft Edge or Internet Explorer when the users clicks on a button.

I've found that the way to do it is calling the System.Diagnostics.Process.Start() but I get:

The type or namespace name 'Process' does not exist in the namespace 'System.Diagnostics'

I've tried to install it with NuGet but I've gotten several Exceptions also...

I've also tried using Launcher, but it hasn't done anything:

await Launcher.LaunchUriAsync(new Uri("LINK"));

Does anyone know how to implement what I need? Thank you!

回答1:

you can use LaunchUriAsync To ask Windows to launch the app associated with a protocol (ex: http://) and pass the Uri to it.

await Windows.System.Launcher.LaunchUriAsync(new Uri("http://danvy.tv"));

In this case, your default browser will open http://danvy.tv .