Asp.Net-创建网站的快捷方式到桌面,开始菜单,收藏夹

 protected void Page_Load(object sender, EventArgs e)
        {
              CreateShortcut("baidu", "http://www.baidu.com");
        }

        /// <summary>
        /// 创建快捷方式
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="URL">URL地址</param>
        public static void CreateShortcut(string Title, string URL)
        {
            try
            {
                string strFavoriteFolder;
                // “收藏夹”中 创建 IE 快捷方式
                strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
                CreateShortcutFile(Title, URL, strFavoriteFolder);
                // “ 桌面 ”中 创建 IE 快捷方式
                strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                CreateShortcutFile(Title, URL, strFavoriteFolder);
                // “ 链接 ”中 创建 IE 快捷方式
                strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites);// + "\\链接"
                CreateShortcutFile(Title, URL, strFavoriteFolder);
                //「开始」菜单中 创建 IE 快捷方式
                strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
                CreateShortcutFile(Title, URL, strFavoriteFolder);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 创建快捷方式
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="URL">URL地址</param>
        /// <param name="SpecialFolder">特殊文件夹</param>
        private static void CreateShortcutFile(string Title, string URL, string SpecialFolder)
        {
            try
            {
                // Create shortcut file, based on Title
                System.IO.StreamWriter objWriter = System.IO.File.CreateText(SpecialFolder + "\\" + Title + ".url");
                // Write URL to file
                objWriter.WriteLine("[DEFAULT]");
                objWriter.WriteLine("BASEURL=" + URL);
                objWriter.WriteLine("[{000214A0-0000-0000-C000-000000000046}]");
                objWriter.WriteLine("Prop3=19,2");
                objWriter.WriteLine("[InternetShortcut]");
                objWriter.WriteLine("URL=" + URL);
                objWriter.WriteLine("IDList=");
                objWriter.WriteLine("IconFile=" + URL + "favicon.ico");
                objWriter.WriteLine("IconIndex=1");
                // Close file
                objWriter.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhanglong_longlong/article/details/12611523
个人分类: asp.net
上一篇服务器控件OnClientClick调用js
下一篇HttpModule与HttpHandler详解
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭