asp.net code to generate various Web shortcuts (desktop URL shortcuts, Favorites/Start Menu shortcuts) _ Practical Tips

Source: Internet
Author: User
Copy Code code as follows:

Using System;
Using System.Data;
Using System.Configuration;
Using System.Collections;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
public partial class CreateShortcut:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
}
<summary>
Create shortcuts
</summary>
<param name= "title" > title </param>
<param name= "URL" >url address </param>
private void CreateShortcut (String Title, String URL)
{
String Strfavoritefolder;
Create IE shortcuts in Favorite Folders
Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.Favorites);
Createshortcutfile (Title, URL, Strfavoritefolder);
Create IE shortcuts in desktop
Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.Desktop);
Createshortcutfile (Title, URL, Strfavoritefolder);
Create IE shortcuts in links
Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.Favorites) + "\ Link";
Createshortcutfile (Title, URL, Strfavoritefolder);
Create IE shortcut from Start menu
Strfavoritefolder = System.Environment.GetFolderPath (Environment.SpecialFolder.StartMenu);
Createshortcutfile (Title, URL, Strfavoritefolder);
}
<summary>
Create shortcuts
</summary>
<param name= "title" > title </param>
<param name= "URL" >url address </param>
<param name= "SpecialFolder" > Special folders </param>
private void Createshortcutfile (String Title, String URL, String specialfolder)
{
Create shortcut file, based on Title
System.IO.StreamWriter objwriter = System.IO.File.CreateText (SpecialFolder + "\" + Title + ". url");
Write URL to File
Objwriter.writeline ("[Internetshortcut]");
Objwriter.writeline ("url=" + URL);
Close File
Objwriter.close ();
}
private void Btnshortcut_click (object sender, System.EventArgs e)
{
CreateShortcut ("cloud-dwelling community", http://www.jb51.net);
}
}
Related Article

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.