Spotify.NET/SpotifyAPI.Web.Auth/AuthUtil.cs

30 lines
761 B
C#
Raw Permalink Normal View History

using System.Diagnostics;
using System.Runtime.InteropServices;
namespace SpotifyAPI.Web.Auth
{
internal static class AuthUtil
{
public static void OpenBrowser(string url)
{
2018-09-04 13:39:07 +01:00
#if NETSTANDARD2_0
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
2018-09-04 13:39:07 +01:00
#else
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
2018-09-04 13:39:07 +01:00
#endif
}
}
}