Asp.Net实现网站的快捷方式
Asp.Net实现网站的快捷方式Asp.Net实现网站的快捷方式的代码:
/// <summary>
/// 创建快捷方式
/// </summary>
/// <param name="Title">标题</param>
/// <param name="URL">URL地址</param>
/// <param name="SpecialFolder">特殊文件夹</param>
private static void CreateShortcutFile(string Title, string URL, string SpecialFolder)
{
try
{
// Create shortcut file, based on Title
System.IO.StreamWriter objWriter = System.IO.File.CreateText(SpecialFolder + "\\\\" + Title + ".url");
// Write URL to file
objWriter.WriteLine("[DEFAULT]");
objWriter.WriteLine("BASEURL=" + URL);
objWriter.WriteLine("[{000214A0-0000-0000-C000-000000000046}]");
objWriter.WriteLine("Prop3=19,2");
objWriter.WriteLine("[InternetShortcut]");
objWriter.WriteLine("URL=" + URL);
objWriter.WriteLine("IDList=");
objWriter.WriteLine("IconFile=" + URL + "favicon.ico");
objWriter.WriteLine("IconIndex=1");
// Close file
objWriter.Close();
}
catch (Exception ex)
{
Common.WriteLog(ex.ToString());
}
}
/// <summary>
/// 创建快捷方式
/// </summary>
/// <param name="Title">标题</param>
/// <param name="URL">URL地址</param>
public static void CreateShortcut(string Title, string URL)
{
try
{
string strFavoriteFolder;
// “收藏夹”中 创建 IE 快捷方式
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
CreateShortcutFile(Title, URL, strFavoriteFolder);
// “ 桌面 ”中 创建 IE 快捷方式
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
CreateShortcutFile(Title, URL, strFavoriteFolder);
// “ 链接 ”中 创建 IE 快捷方式
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites) + "\\\\链接";
CreateShortcutFile(Title, URL, strFavoriteFolder);
//「开始」菜单中 创建 IE 快捷方式
strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
CreateShortcutFile(Title, URL, strFavoriteFolder);
}
catch (Exception ex)
{
Common.WriteLog(ex.ToString());
}
}
调用代码 : Common.CreateShortcut("goec", http://www.studyofnet.com/);