0 votes
by (120 points)
edited

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
by (120 points)
edited

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...

by (58.9k points)
edited

Could you describe how we can reproduce this problem?

1 Answer

0 votes
by (58.9k points)
edited

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.

by (120 points)
edited

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.

by (120 points)
edited

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.

by (58.9k points)
edited

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

...