/// <summary>
/// 生成快捷方式
/// </summary>
/// <param name="targetPath">原目标位置</param>
/// /// <param name="savePath">保存快捷方式的位置</param>
protected void CreateShortcuts(String targetPath, String savePath,String saveName)
{
IWshRuntimeLibrary.IWshShell shell_class = new IWshRuntimeLibrary.IWshShell_ClassClass();
IWshRuntimeLibrary.IWshShortcut shortcut = null;
if (!Directory.Exists(targetPath))
return;
if (!Directory(savePath))
Directory.CreateDirectory(savePath);
try
{
shortcut = shell_class.CreateShortcut(savePath + @"/" + saveName + ".lnk") as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = targetPath;
shortcut.Save();
MessageBox.Show("创佳快捷方式成功!");
}
catch (Exception ex)
{
MessageBox.Show("创佳快捷方式失败!");
}
}
/// <summary>
/// 添加收藏夹
/// </summary>
/// <param name="url">对应的网页的url</param>
/// <param name="saveName">保存的名称</param>
/// <param name="folderName">文件夹名称</param>
protected void AddToFavorites(String url, String saveName, String folderName)
{
System.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(new Uri(url));
request.Method = "GET";
request.Timeout = 10000;
try
{
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
//获取当前用户的收藏夹的物理文件夹位置
String favoritesPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
String savePath = favoritesPath;
if (!String.IsNullOrEmpty(folderName))
{
savePath += @"/" + folderName;
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
}
IWshRuntimeLibrary.WshShell shell_class = new IWshRuntimeLibrary.WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut = null;
try
{
shortcut = shell_class.CreateShortcut(favoritesPath + @"/" + saveName + ".lnk") as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = url;
shortcut.Save();
MessageBox.Show("添加成功");
}
catch (Exception ex)
{
MessageBox.Show("添加失败");
}
}
else
{
MessageBox.Show("请求失败");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有