Asp.net生成各种网页快捷方式
2011-01-15 10:11 omgee 阅读(649) 评论(3) 编辑 收藏 举报 1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12 public partial class CreateShortcut : System.Web.UI.Page
13 {
14 protected void Page_Load(object sender, EventArgs e)
15 {
16 }
17
18 /// <summary>
19 /// 创建快捷方式
20 /// </summary>
21 /// <param name="Title">标题</param>
22 /// <param name="URL">URL地址</param>
23 private void CreateShortcut(string Title, string URL)
24 {
25 string strFavoriteFolder;
26
27 // “收藏夹”中 创建 IE 快捷方式
28 strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
29 CreateShortcutFile(Title, URL, strFavoriteFolder);
30
31 // “ 桌面 ”中 创建 IE 快捷方式
32 strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
33 CreateShortcutFile(Title, URL, strFavoriteFolder);
34
35 // “ 链接 ”中 创建 IE 快捷方式
36 strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites) + "\\链接";
37 CreateShortcutFile(Title, URL, strFavoriteFolder);
38
39 //「开始」菜单中 创建 IE 快捷方式
40 strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
41 CreateShortcutFile(Title, URL, strFavoriteFolder);
42
43 }
44
45 /// <summary>
46 /// 创建快捷方式
47 /// </summary>
48 /// <param name="Title">标题</param>
49 /// <param name="URL">URL地址</param>
50 /// <param name="SpecialFolder">特殊文件夹</param>
51 private void CreateShortcutFile(string Title, string URL, string SpecialFolder)
52 {
53 // Create shortcut file, based on Title
54 System.IO.StreamWriter objWriter = System.IO.File.CreateText(SpecialFolder + "\\" + Title + ".url");
55 // Write URL to file
56 objWriter.WriteLine("[InternetShortcut]");
57 objWriter.WriteLine("URL=" + URL);
58 // Close file
59 objWriter.Close();
60 }
61
62 private void btnShortcut_Click(object sender, System.EventArgs e)
63 {
64 CreateShortcut("IT鸟的专栏 - 博客圆", http://www.cnblogs.com/ITniao/);
65 }
66 }
生成pdf http://www.cnblogs.com/Joetao/articles/2933941.html
转至IT鸟的专栏