如何在C#中删除快捷方式文件 [英] How to remove a shortcut file in c#

查看:51
本文介绍了如何在C#中删除快捷方式文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从程序"文件夹中删除程序图标?

How to remove the program icon from the Programs folder?

推荐答案

要获取开始菜单的位置,请使用

To get the start menu location, use the SpecialFolder enumeration. Something like the following should get you started:

string startMenuDir = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
string shortcut = Path.Combine(startMenuDir, @"The Company\MyShortcut.lnk");
if (File.Exists(shortcut))
    File.Delete(shortcut);

如果您不知道确切的文件名,则可以使用 Directory.Delete

If you don't know the exact file name, you could enumerate over all the files in the start menu folder using Directory.GetFiles or Directory.GetDirectories. You could also remove the entire folder ("The Company"), using Directory.Delete

这篇关于如何在C#中删除快捷方式文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆