如何以编程方式从用户桌面删除快捷方式?
使用 C#,如何从用户桌面删除快捷方式?
尝试过但没有成功:
string WinUser = WindowsIdentity.GetCurrent().Name;
WinUser = WinUser.Substring(WinUser.LastIndexOf("\\") + 1);
File.Delete("C:\\Users\\" + WinUser + "\\Desktop\\Touch Data.lnk");
我错过了什么?感谢对此的任何建议!
Using C#, how can I delete a shortcut from a user's desktop?
Tried this with no success:
string WinUser = WindowsIdentity.GetCurrent().Name;
WinUser = WinUser.Substring(WinUser.LastIndexOf("\\") + 1);
File.Delete("C:\\Users\\" + WinUser + "\\Desktop\\Touch Data.lnk");
What am I missing? Appreciate any advice on this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请尝试以下操作:
Try the following:
我在这个问题中遇到了这个问题:
为什么当 RootFolder 是 MyComputer 时,FolderBrowserDialog 不允许桌面作为 SelectedPath?
我得到的答案是这样的:
有可能这就是问题所在。您应该使用Environment.GetFolderPath 函数来获取真实桌面的句柄。 :)
I had this issue in this question I asked:
Why does FolderBrowserDialog not allow the desktop as SelectedPath when RootFolder is MyComputer?
The answer I got was this:
It's possible this is the issue. You should use the Environment.GetFolderPath function to get a handle on the real desktop. :)
我遇到了同样的情况,我必须检查快捷方式是否存在然后将其删除。我使用了以下代码
I had the same scenario where I had to check if the shortcut exists and then delete it. I used the following code
:)) win7 标准用户名 public
:)) win7 standart user name public