Solved

How do I locate and "re-target" a shortcut (.lnk)

Posted on 2003-12-03
1
375 Views
Last Modified: 2013-11-18
I need to write a C# method that will find and "re-target" all shortcuts (eg  .lnk files) that point to a specific target.  I've found some WSH (windows scripting host) examples of creating shortcuts, but I can't seem to find anything that will locate all shortcuts that point to a specific target.

0
Comment
Question by:wile_e_coyote
1 Comment
 
LVL 22

Accepted Solution

by:
_TAD_ earned 250 total points
Comment Utility


Here is a quick utility to get all of the file pathways with an *.lnk extension.



            private void button1_Click(object sender, System.EventArgs e)
            {
                  ArrayList mylist = GetFiles(@"C:\Documents and Settings","*.lnk",new ArrayList());
                  FileInfo f;

                  for(int i=0;i<mylist.Count;i++)
                        Console.WriteLine(mylist[i].ToString());

            }



            private ArrayList GetFiles(string path, string fileType, ArrayList fileList)
            {
                  string[] childDirectories;
                  string[] files;
                        
                  // find all dlls in the parent and child directories
                  files = Directory.GetFileSystemEntries(path, fileType);
                  
                  for(int i=0;i<files.Length;i++)
                        fileList.Add(files[i]);
                              

                  // load an array list with all of the valid plug-ins
                  childDirectories = Directory.GetDirectories(path);
                  for(int i=0;i<childDirectories.Length;i++)
                        fileList = GetFiles(childDirectories[i], fileType, fileList);

                  return fileList;
            }



But as far as changing the contents of those files... I think you'll need to use WIN API for that.   As far as I know, .NET cannot change the properties of shortcut links.  .Net only manipulates actual files... not the links to files.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now