asp.net 產生案頭捷徑代碼

來源:互聯網
上載者:User

 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.111cn.net/);
65     }
66 }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.