[c#] Accessing the target path of a shortcut (*.lnk)?

Caporegime
Joined
18 Oct 2002
Posts
29,491
Location
Back in East London
I've been banging my head on my desk for ten minutes. I'm simply trying to find the target path of a shortcut file. I have seen examples that read the .lnk as a binary and parse the data, but I'd rather hope there was a more standard, higher level way of doing this. In semi-pseudo I just want to be able to:
Code:
ShortcutFile file = new ShortcutFile("c:\dir\shortcut.lnk");
String target = file.TargetPath;
but it seems this is not the case.

I've looked around MSDN and google for sometime and the closest I got was Windows Scripting Object COM library (IWshRuntimeLibrary) but it spits the fallback COM error (the defacto "'unknown error' error")

Help?! :(
 
Caporegime
OP
Joined
18 Oct 2002
Posts
29,491
Location
Back in East London
I've got all those.. that particular error was because I have to use WshShellClass(), rather than WshShell() - which is why I asked the version.

I'm also accessing the file across the network.. so the filename is \\server\share\file.lnk format.
 
Back
Top Bottom