title: Accessing a file through System.IO while a folder in the path is a shortcut
body: <p>I have to create a file and the path to the file contains a folder that is actually a shortcut.</p>
  
  <p>Example:</p>
  
  <p><code>D:\SQL Backups\LocumsExcite_04-Sep-2013 16-36-59-135.bak</code></p>
  
  <p>The <code>SQL Backups</code> folder is a shortcut in <code>D:</code> drive. The shortcut takes us to <code>C:\Users\Administrator\Dropbox\SQL Backups\</code> folder</p>
  
  <p>I looked at the Shell examples everywhere but its not working for me.</p>
  
  <pre><code>public static string GetShortcutTarget(string shortcutFilename)
      {
          string pathOnly = System.IO.Path.GetDirectoryName(shortcutFilename);
          string filenameOnly = System.IO.Path.GetFileName(shortcutFilename);
  
          Shell32.Shell shell = new Shell32.ShellClass();
          Shell32.Folder folder = shell.NameSpace(pathOnly);
          Shell32.FolderItem folderItem = folder.ParseName(filenameOnly);
  
          if (folderItem != null)
          {
              if (folderItem.IsLink)
              {
                  Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink;
                  return link.Path;
              }
              return shortcutFilename;
          }
          return "";  // not found
      }
  </code></pre>
  
  <p>The line <code>shell.NameSpace(pathOnly);</code> always return a null. Any suggestions?</p>