Hello,
I've been asked to write a sort of "desktop clean-up" utility.
Requirements are simple: iterate through the shortcuts (*.lnk files) on the
currently logged-on user's desktop, and delete each link whose TargetPath
property no longer exists.
Iterating through the shortcuts on the desktop is easy enough using
Directory.GetFiles(*.lnk)
I found the following article which explains how to inspect the various
properties of a shortcut:
http://www.codeproject.com/useritems/Starter.asp
This uses COMInterop to inspect the shortcuts.
The author of the article says that he doesn't believe a managed solution is
available for this. Is this true?
I don't really have a problem using COMInterop but I guess I'd prefer to use
a managed solution if possible.
Does anyone know if there is one?
Thanks,
DJ
Nicholas Paldino [.NET/C# MVP] - 25 Jun 2007 17:50 GMT
David,
Well, there isn't a native managed wrapper for it if that is what you
mean, or a managed way to parse the files and get the contents.
COM interop is as managed as it is going to get.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hello,
>
[quoted text clipped - 24 lines]
>
> DJ
David Jackson - 26 Jun 2007 10:02 GMT
Hi Nicholas,
Thanks for the reply
> Well, there isn't a native managed wrapper for it if that is what you
> mean, or a managed way to parse the files and get the contents.
>
> COM interop is as managed as it is going to get.
OK.
DJ
G Himangi - 26 Jun 2007 06:51 GMT
Take a look at ShellLink component from ShellObjects at
http://www.ssware.com/shlobj/shlobj.htm
> Hello,
>
[quoted text clipped - 24 lines]
>
> DJ
David Jackson - 26 Jun 2007 10:09 GMT
Hi G,
Thanks for the reply.
> Take a look at ShellLink component from ShellObjects at
> http://www.ssware.com/shlobj/shlobj.htm
That certainly does look like it would do the job, and a whole lot more!
However, as this is very much a "nice-to-have", I don't really think I can
justify the expense, even at $95.
Thanks again.
DJ