2

I am using on WPF Win32 file browser dialog to select a file in the filesystem. Now my problem is, when I select an shortcut file ending with .ink, it shows the application path not the shortcut(.ink) path.

For example I want to select snoop shortcut

Shortcut

as filepath, I've got.

Filepath

How can I get the path from shortcut not from application?

Update I am trying restrict with

 Win32.OpenFileDialog ofd = new Win32.OpenFileDialog();
 ofd.Filter = "Link (*.lnk)|*.lnk";

but only .lnk it is possible to select. It should be possible to select other files too, not only .lnk file.

softshipper
  • 32,463
  • 51
  • 192
  • 400
  • Related: http://stackoverflow.com/questions/15758941/how-to-get-the-current-directory-path-of-applications-shortcut and http://stackoverflow.com/questions/9414152/get-target-of-shortcut-folder – Soner Gönül Sep 22 '14 at 07:06
  • this is usually how shortcut works, try http://stackoverflow.com/questions/2350802/can-the-net-openfiledialog-be-setup-to-allow-the-user-to-select-a-lnk-file to get the lnk file itself – pushpraj Sep 22 '14 at 07:08

1 Answers1

3

You must use OpenFileDialog.DereferenceLinks property.

Gets or sets a value indicating whether a file dialog returns either the location of the file referenced by a shortcut or the location of the shortcut file (.lnk).

odf.DereferenceLinks = false;

For the update question, just add All Files|*.*| :

ofd.Filter = "All Files|*.*|Link (*.lnk)|*.lnk";
Xaruth
  • 4,034
  • 3
  • 19
  • 26