Asp.NET generates code for various web shortcuts (desktop url favorites and start menu shortcuts)

  • 2020-05-12 02:31:04
  • OfStack

 
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"> The title </param> 
/// <param name="URL">URL address </param> 
private void CreateShortcut(string Title, string URL) 
{ 
string strFavoriteFolder; 
//  In "favorites.   create  IE  A shortcut  
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites); 
CreateShortcutFile(Title, URL, strFavoriteFolder); 
//  "   desktop   In the"   create  IE  A shortcut  
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop); 
CreateShortcutFile(Title, URL, strFavoriteFolder); 
//  "   link   In the"   create  IE  A shortcut  
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites) + "\\ link "; 
CreateShortcutFile(Title, URL, strFavoriteFolder); 
// "Start" menu   create  IE  A shortcut  
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); 
CreateShortcutFile(Title, URL, strFavoriteFolder); 
} 
/// <summary> 
///  Create shortcuts  
/// </summary> 
/// <param name="Title"> The title </param> 
/// <param name="URL">URL address </param> 
/// <param name="SpecialFolder"> Special folder </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(" The home of the script ", //www.ofstack.com); 
} 
} 

Related articles: