C#中JumpList实现报错求助:CS0176与CS1503问题
解决JumpList使用中的两个编译错误
错误1:CS0176
JumpList.AddToRecent(string)是静态方法,不能通过JumpList实例调用,必须直接用类型名JumpList来调用。
错误2:CS1503
JumpListLink的构造函数第一个参数要求传入字符串格式的可执行文件路径,而非System.Uri对象,直接传入路径字符串即可。
修正后的完整代码
if (TaskbarManager.IsPlatformSupported) { // Create a jump list JumpList jumpList = JumpList.CreateJumpList(); // Add recent items - 使用类名调用静态方法 JumpList.AddToRecent("C:\\Path\\To\\RecentFile.txt"); // Add custom tasks - 直接传入字符串路径 JumpListLink customTask = new JumpListLink("C:\\Path\\To\\Executable.exe", "Custom Task"); jumpList.AddUserTasks(customTask); // Save the jump list jumpList.Refresh(); }
内容的提问来源于stack exchange,提问作者user23179962
相关产品推荐
相关产品推荐

