并在引用里添加一个COM 代码如下 1string path=Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites);要创建快捷方式需要用到IWshRuntimeLibrary命名空间 肯定是vs了
|||
一楼太强大了彻底服了很正确很不错
string filename
要获得收藏加目录可以用GetFolderPath方法来完成 string savepath) { string path=Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites); if( 添加到收藏夹方法如下“public void addFavorites(string url 在这里我们要USING一下 System.IO.File.Exists(path+"//"+filename+savepath+".url")) { IWshShell_Class shell = new IWshShell_ClassClass(); IWshURLShortcut shortcut=null; if (savepath == "Favorites") { shortcut = shell.CreateShortcut(Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "//" + filename + ".url") as IWshURLShortcut; } else { shortcut = shell.CreateShortcut(Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "//" + savepath + "//" + filename + ".url") as IWshURLShortcut; } shortcut.TargetPath = url; shortcut.Save(); } }
答案补充
是的 windows script host object model
收藏夹怎么做啊
最新推荐文章于 2026-01-01 16:29:13 发布
本文介绍了一种方法,可以通过编程的方式将指定网址添加到Windows系统的收藏夹中。具体实现时,利用了Environment.GetFolderPath方法获取收藏夹路径,并使用IWshShell_Class创建快捷方式。
472

被折叠的 条评论
为什么被折叠?



