使用Process.Start打开文件夹或网页

  代码
        /// <summary>
        /// 打开文件所在的文件夹
        /// </summary>
        public static void OpenFileDialog(string stringPath)
        {
            System.Diagnostics.Process.Start("explorer", "/select," + stringPath);
        }
        /// <summary>
        /// 打开指定网页
        /// </summary>
        public static void OpenNetPage(string url)
        {
            System.Diagnostics.Process.Start("iexplore", url);//System.Diagnostics.Process.Start(url);默认浏览器打开
        }

调用

          OpenFileDialog(@"C:\Program Files");

          OpenNetPage(@"http://www.baidu.com");


 

你可能感兴趣的:(c,String,浏览器,url)