How can i get a shortcut of a target file on my hard disk?
<p>Im trying to use this function but getting some errors:</p>

<pre><code>public string GetShortcutTargetFile(string shortcutFilename)
        {
            string pathOnly = System.IO.Path.GetDirectoryName(shortcutFilename);
            string filenameOnly = System.IO.Path.GetFileName(shortcutFilename);

            Shell shell = new Shell();
            Folder folder = shell.NameSpace(pathOnly);
            FolderItem folderItem = folder.ParseName(filenameOnly);
            if (folderItem != null)
            {
                Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink;
                return link.Path;
            }

            return string.Empty;
        }

        static void Main(string[] args)
        {
            const string path = @"C:\link to foobar.lnk";
            Console.WriteLine(GetShortcutTargetFile(path));
        }
</code></pre>

<p>The first error is on the line :</p>

<pre><code>Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink;
</code></pre>

<p>On the right hand of the line (Shell32.ShellLinkObject)folderItem.GetLink
Im getting errors:</p>

<pre><code>Error   2   One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?
</code></pre>

<p>And on the line in the end:</p>

<pre><code>Console.WriteLine(GetShortcutTargetFile(path));
</code></pre>

<p>The error is on the: GetShortcutTargetFile(path) the function was static but i removed the static and then i mgetting the error in the last line.</p>

<pre><code>Error   4   An object reference is required for the non-static field, method, or property 'GatherLinks.Form1.GetShortcutTargetFile(string)
</code></pre>

<p>How can i fix all the errors and how to get all the shortucts that target files ?</p>
