Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to code a software that search for the broken shortcuts in the Hard Drive. How can I achieve this? Can you give me an idea on how to go about this? Thank you.
Posted

1 solution

Pseudo Code:
C#
foreach(link in RecursivelyGetAllLinksOf(path))
{
    if (!File.Exists(link.Ref))
    {
        Error("Error in {0}: Reference {1} does not exist", link.Path, link.Ref);
    }
    if (!Directory.Exists(link.WorkDir))
    {
        Error("Error in {0}: Work directory {1} does not exist", link.Path, link.WorkDir);
    }
}


Is it this what you ask for?

[EDIT]
Have a look at:
- How can I test programmatically if a path/file is a shortcut?[^]
- How to Utilise the Shell32 Library in .NET as a COM Import – A Neat little Hack[^]
- Windows® API Code Pack for Microsoft® .NET Framework[^]
[/EDIT]

Cheers
Andi
 
Share this answer
 
v4
Comments
phantomlakshan 10-Feb-13 6:08am    
Would you be able to give me the C# code?
Andreas Gieriet 10-Feb-13 6:20am    
No. Sorry. Your task. Homework?
Andi
Sergey Alexandrovich Kryukov 10-Feb-13 9:01am    
The only problem is the implementation of "link.Ref". It's more considerable problem than everything around it, as it, to best of my knowledge, required either P/Invoke, access to a COM component implementing Shell, Windows Scripting Host or the like, not directly available in .NET FCL. If it is available, please advise.
—SA
Andreas Gieriet 10-Feb-13 10:51am    
See How can I test programmatically if a path/file is a shortcut?. It also provides the detection if some item is a short-cut but also provides all information needed to access the short-cut's elements. See also How to Utilise the Shell32 Library in .NET as a COM Import – A Neat little Hack for accessing these functions. There is also a MSDN download to access shell/shell extension from .Net: Windows® API Code Pack for Microsoft® .NET Framework.
Cheers
Andi
Sergey Alexandrovich Kryukov 10-Feb-13 13:12pm    
Yes, I understand how it works and how to solve the problem using it, but will it be clear to OP?
Anyway, good link, my 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900