Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > BOOK: Beginning Visual C#
|
BOOK: Beginning Visual C#
This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2006, 12:29 PM
Authorized User
 
Join Date: Dec 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieve target location from a link file

Hi everyone,
I have several shortcut files on my desktop and need to find out how to retrieve the target location of each shortcut goes programmatically. So far I managed to get all my link files on my desktop as shown in the code but I have no idea how to retrieve target location information from each shortcuts. Could anyone help please?

Code:
            IDictionary environmentVariables = Environment.GetEnvironmentVariables();
            string dd = environmentVariables["USERPROFILE"].ToString() + "\\Desktop";

            string[] files= Directory.GetFiles(dd, "*.lnk");

            foreach (string file in files) {
                MessageBox.Show(file);
                //Get target location of each lnk file
            }
 
Old March 6th, 2007, 11:54 AM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

References: Microsoft Scripting Runtime

example of cell.text: "D:\Home Drive\myexcelfileshortcut.xls.lnk"

Sub shortcutTarget()
Dim Shortcut, WshShell
Dim cell As Range

Set WshShell = CreateObject("WScript.Shell")

Application.ScreenUpdating = False

For Each cell In Selection
    Set Shortcut = WshShell.CreateShortcut(cell.Text)
    Cells(cell.row, 2) = Shortcut.TargetPath
Next

Application.ScreenUpdating = True

End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
separate file location for different databases Aprile MySQL 1 September 6th, 2007 04:34 PM
File Location AlexSepahpour ASP.NET 2.0 Basics 0 March 11th, 2007 12:58 AM
Configuration file name and location TomH VB Databases Basics 2 September 29th, 2006 06:59 PM
Save file location code. JpaulH Access VBA 2 June 9th, 2006 07:50 AM
Download a file from http location sarath_lal007 ASP.NET 1.0 and 1.1 Professional 1 February 17th, 2006 05:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.