Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: C# FTP download symlinked file

Martin, it's much appreciated, the time you take for post like this.

I think it would be faster if you spin up a dev-version of WinSCP yourself, and use the code posted in the first post.
I can live with my workaround, as this is just a hobby project.

Re: C# FTP download symlinked file

This change should help you:

Can you send me an email, so I can send you back a development version of WinSCP? Please include link back to this topic in your email. Also note in this topic that you have sent the email. Thanks.

You will find my address (if you log in) in my forum profile.

Re: C# FTP download symlinked file

Yes, here's how I get around it:
// Can't get symlink to work even with rawsetting, so executing this to get the real link
var commandResult = session.ExecuteCommand($"CWD {remotePath}");
//250 OK. Current directory is /.m/mirrors1l/
var pathToRemoteFile = $"{commandResult.Output.Replace("250 OK. Current directory is ", "")}/{remoteFileName}";

But would have liked a cleaner way, than the above.
Remember, that I can't just hardcode the current symlinked path, as this may change (and most likely will, as it looks like a load-balanced link).


Re: C# FTP download symlinked file

So did you try using the actual path, instead of the path to the symlink?

C# FTP download symlinked file


I'm having trouble downloading a file from IMDb's alternative interfaces FTP, which seems to have symlinks for files.

The error returned:

Error transferring file '/pub/mirrors/'.
Real path and requested remote path do not match: "/.m/mirrors1l/" "/pub/mirrors/"
Copying files from remote side failed.

Searching through this forum, there are old posts from 2002 stating that symlinks are not supported, and then more recent posts, pointing to: and

Tried adding the rawsettings, but to no avail:
   var sessionOptions = new SessionOptions
      Protocol = Protocol.Ftp
   sessionOptions.AddRawSettings("ResolveSymlinks", "1");
   sessionOptions.AddRawSettings("FollowDirectorySymlinks", "1");
   using (Session session = new Session())
      session.FileTransferProgress += progressHandler;
      TransferOptions transferOptions = new TransferOptions();
      transferOptions.TransferMode = TransferMode.Binary;
      var transferResult = session.GetFiles(
catch (Exception e)
   Debug.WriteLine("Error: {0}", e);

Tried to see if I could get the translated symlink using EnumerateRemoteFiles or ListDirectory, but the file's FullName is still the symlinked path.
The only option I have so far, is to catch the exception, parse the Message to get the real path and make a second call to GetFiles(), which is as hacky as it gets.

Any pointers would be much appreciated.