收藏夹怎么做啊

来源:互联网 发布:gta5捏脸数据女二次元 编辑:程序博客网 时间:2024/04/20 12:57
并在引用里添加一个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
原创粉丝点击