Groups | Blog | Home
all groups > dotnet framework > october 2007 >

dotnet framework : Get a shortcut target path


Paulo_Amaral
10/11/2007 8:49:06 AM
Hello,

My question seens very simple: i want to write a function like
private string ResolveLink(string LinkFilePath) { ... }
that receives, for example, "c:\\myshortcut.lnk" and gives back the
shortcut's target path. Just the target's path.

Paulo_Amaral
10/11/2007 12:08:00 PM
Found the solution:

Add the COM reference: Windows Script Host Object Model

Code:

using IWshRuntimeLibrary;

private string Resolve(string LnkFilePath)
{
WshShell shell = new WshShellClass();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(LnkFilePath);
return link.TargetPath;
}



[quoted text, click to view]
AddThis Social Bookmark Button