Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 10-Feb-13 0:36am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Pseudo Code:
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
  Permalink  
v4
Comments
phantomlakshan at 10-Feb-13 6:08am
   
Would you be able to give me the C# code?
Andreas Gieriet at 10-Feb-13 6:20am
   
No. Sorry. Your task. Homework?
Andi
Sergey Alexandrovich Kryukov at 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 at 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 at 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
Andreas Gieriet at 10-Feb-13 13:31pm
   
Thanks for your 5!
I've added the links from my comment to the solution.
Cheers
Andi

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

  Print Answers RSS
0 DamithSL 390
1 Maciej Los 217
2 OriginalGriff 213
3 BillWoodruff 135
4 Garth J Lancaster 90
0 OriginalGriff 7,953
1 DamithSL 6,139
2 Sergey Alexandrovich Kryukov 5,449
3 Maciej Los 5,293
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 10 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100