Esempio n. 1
0
        /// <summary>
        ///     Opens an URL.
        /// </summary>
        /// <param name="url"> The URL to open. </param>
        /// <param name="windowStyle"> The window style of the window started by opening the URL. </param>
        /// <param name="elevated"> Specifies whether the URL should be opened with elevated privileges. </param>
        /// <returns>
        ///     true if the URL could be opened, false otherwise.
        /// </returns>
        /// <exception cref="ArgumentNullException"> <paramref name="url" /> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="url" /> is an empty string. </exception>
        /// <exception cref="UriFormatException"> <paramref name="url" /> is not a valid URI. </exception>
        public static bool OpenUrl(string url, ProcessWindowStyle windowStyle, bool elevated)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentException("The string is empty.", nameof(url));
            }

            Uri uri;

            try
            {
                uri = new Uri(url);
            }
            catch (Exception exception)
            {
                throw new UriFormatException(exception.Message, exception);
            }

            return(WindowsShell.OpenUrl(uri, windowStyle, elevated));
        }
Esempio n. 2
0
 /// <summary>
 ///     Opens an URL.
 /// </summary>
 /// <param name="url"> The URL to open. </param>
 /// <returns>
 ///     true if the URL could be opened, false otherwise.
 /// </returns>
 /// <exception cref="ArgumentNullException"> <paramref name="url" /> is null. </exception>
 public static bool OpenUrl(Uri url) => WindowsShell.OpenUrl(url, ProcessWindowStyle.Normal, false);