Standby: ASP. NET generates various webpage shortcuts (desktop URL shortcuts, favorites/Start Menu shortcuts)

Source: Internet
Author: 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 /// Create shortcuts
20 ///   </Summary>
21 ///   <Param name = "title"> Title </Param>
22 ///   <Param name = "url"> URL </Param>
23 Private   Void Createshortcut ( String Title, String URL)
24 {
25 String Strfavoritefolder;
26
27 // Create ie shortcuts in "favorites"
28 Strfavoritefolder = System. environment. getfolderpath (environment. specialfolder. favorites );
29 Createshortcutfile (title, URL, strfavoritefolder );
30
31 // Create ie shortcuts in "desktop"
32 Strfavoritefolder = System. environment. getfolderpath (environment. specialfolder. desktop );
33 Createshortcutfile (title, URL, strfavoritefolder );
34
35 // Create an IE shortcut in "Link"
36 Strfavoritefolder = System. environment. getfolderpath (environment. specialfolder. favorites) +   " \ Link " ;
37 Createshortcutfile (title, URL, strfavoritefolder );
38
39 // Create an IE shortcut in the "Start" menu
40 Strfavoritefolder = System. environment. getfolderpath (environment. specialfolder. startmenu );
41 Createshortcutfile (title, URL, strfavoritefolder );
42
43 }
44
45 ///   <Summary>
46 /// Create shortcuts
47 ///   </Summary>
48 ///   <Param name = "title"> Title </Param>
49 ///   <Param name = "url"> URL </Param>
50 ///   <Param name = "specialfolder"> Special folder </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 bird column-blog circle " , Http://www.cnblogs.com/ITniao/ );
65 }
66 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.