Пример #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));
        }
Пример #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);
Пример #3
0
 /// <summary>
 ///     Opens a command prompt.
 /// </summary>
 /// <returns>
 ///     true if the command prompt could be opened, false otherwise.
 /// </returns>
 public static bool OpenCommandPrompt() => WindowsShell.OpenCommandPrompt(null, false);
Пример #4
0
 /// <summary>
 ///     Opens the Task Manager.
 /// </summary>
 /// <returns>
 ///     true if the Task Manager could be opened, false otherwise.
 /// </returns>
 public static bool OpenTaskManager() => WindowsShell.OpenTaskManager(ProcessWindowStyle.Normal, false);
Пример #5
0
 /// <summary>
 ///     Opens the System Info.
 /// </summary>
 /// <returns>
 ///     true if the System Info could be opened, false otherwise.
 /// </returns>
 public static bool OpenSystemInfo() => WindowsShell.OpenSystemInfo(ProcessWindowStyle.Normal, false);
Пример #6
0
 /// <summary>
 ///     Opens a folder in Windows Explorer.
 /// </summary>
 /// <param name="folderPath"> The folder path to open. </param>
 /// <returns>
 ///     true if the folder could be opened, false otherwise.
 /// </returns>
 /// <remarks>
 ///     <para>
 ///         Environment variables will be resolved for <paramref name="folderPath" />.
 ///     </para>
 /// </remarks>
 /// <exception cref="ArgumentNullException"> <paramref name="folderPath" /> is null. </exception>
 /// <exception cref="ArgumentException"> <paramref name="folderPath" /> is an empty string. </exception>
 public static bool OpenFolder(string folderPath) =>
 WindowsShell.OpenFolder(folderPath, ProcessWindowStyle.Normal, false);
Пример #7
0
 /// <summary>
 ///     Opens a file with its associated program.
 /// </summary>
 /// <param name="filePath"> The file path to open. </param>
 /// <returns>
 ///     true if the file could be opened, false otherwise.
 /// </returns>
 /// <remarks>
 ///     <para>
 ///         Environment variables will be resolved for <paramref name="filePath" />.
 ///     </para>
 /// </remarks>
 /// <exception cref="ArgumentNullException"> <paramref name="filePath" /> is null. </exception>
 /// <exception cref="ArgumentException"> <paramref name="filePath" /> is an empty string. </exception>
 public static bool OpenFile(string filePath) =>
 WindowsShell.OpenFile(filePath, ProcessWindowStyle.Normal, false);
Пример #8
0
 /// <summary>
 ///     Opens the Windows Explorer.
 /// </summary>
 /// <returns>
 ///     true if the Windows Explorer could be opened, false otherwise.
 /// </returns>
 public static bool OpenExplorer() => WindowsShell.OpenExplorer(ProcessWindowStyle.Normal, false);