【发布时间】:2017-01-24 09:53:09
【问题描述】:
我正在尝试制作一个可以创建回收站快捷方式的控制台应用程序。
我的代码:
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
object shDesktop = (object)"Desktop";
WshShell shell = new WshShell();
string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\Recycle Bin.lnk";
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = "New shortcut for Recycle Bin";
shortcut.Hotkey = "Ctrl+Shift+N";
shortcut.IconLocation = @"C:\WINDOWS\System32\imageres.dll";
shortcut.TargetPath = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\Recycle.Bin";
shortcut.Save();
它创建了一个“快捷方式”,但它根本不可用。时会弹出一条消息。我尝试打开它会产生:
“Windows 正在搜索 recycle.bin。要自行查找文件,请单击浏览。”
【问题讨论】:
-
欢迎使用 Stack Overflow。请删除thanks in advance 部分。
-
那么是什么让您认为回收站是一个名为
Recycle.Bin的独立文件?你知道 Windows 中有一个设置可以在桌面上显示回收站吗? -
我的回收站已经可见,但你的意思是什么?也许我误解了你的回答..
-
我当然不认为 c:\windows\system32\recycle.bin 是正确的路径,我认为它始终是驱动器的根目录并称为 $recycle.bin
-
这不是一个答案,而是一个问题。你想做什么?
标签: c# windows-shell desktop-shortcut