?
Solved

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

Posted on 2003-12-03
1
Medium Priority
?
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
_TAD_ earned 750 total points
ID: 9870936


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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

752 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