Download .lnk files

0 votes
asked Aug 12, 2013 by Dmitry Kustov (120 points)
edited Aug 23, 2013

Dear users, can you, please, advise how can I download .lnk files (that is shortcuts)? I understand how to skip them, how to "follow" them if the link is actually valid, but if the link is to a non-existing file it becomes a problem. I need to download it as a standard file. SO... How can I download .lnk as a file? Using SFTP.

Applies to: Rebex SFTP
commented Aug 12, 2013 by Dmitry Kustov (120 points)
edited Aug 12, 2013

Also, I've noticed that in some cases even if links are set to be skipped and a link is for a non-existing file it still tries to add it while traversing...

commented Aug 13, 2013 by Tomas Knopp (58,890 points)
edited Aug 13, 2013

Could you describe how we can reproduce this problem?

1 Answer

0 votes
answered Aug 13, 2013 by Tomas Knopp (58,890 points)
edited Aug 13, 2013

Hello,

*.lnk files are in fact "normal" files which are treated in a special way by Windows applications. The structure of the file contains information about the Windows shortcut.

It depends on the SFTP server, whether it will actually treat the *.lnk file as a link or simply as a file (the latter is much more probable).

Even testing a Windows based SFTP server (Bitvise) - we can see that Bitvise does not "understand" .lnk shortcuts and simply treats the .lnk as a file. And for SFTP servers running on Unix systems the *.lnk does not have a meaning.

So if you want to download the *.lnk file as a file, it should be enough to write:

Using sftp As New Rebex.Net.Sftp
    ' connect to a server
    sftp.Connect(hostname)
    ' authenticate
    sftp.Login(username, password)

    ' download a file
    sftp.Download("/MyData/shortcut.lnk", "C:\MyData")

    ' disconnect (not required, but polite)
    sftp.Disconnect()
End Using

However if you want to download the file to which the Windows shortcut points, you would have to write a *.lnk parser of your own, find what is the item to which the shortcut points, and then download the linked file using the code above.

commented Aug 13, 2013 by Dmitry Kustov (120 points)
edited Aug 13, 2013

Turns out it's a server issue. Disregard the fact that shortcut interpretation is disabled it tries to convert .lnk files and I get errors like MediaCenterShortcut.lnk/MediaCenterShortcut.lnk: open for read: no such file or directory That is .lnk filename gets duplicated.

commented Aug 13, 2013 by Dmitry Kustov (120 points)
edited Aug 13, 2013

I'm gonna report this to server developers, but if anyone has an idea how to work around this through Rebex - would be much appreciated.

commented Aug 13, 2013 by Tomas Knopp (58,890 points)
edited Aug 13, 2013

Thank you for reporting back to us. However, we do not have an idea how to work around this issue with Rebex... Sorry.

...