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: .NET Assembly Session.MoveFile Method Problem

You use the script as a custom command from WinSCP?

Re: .NET Assembly Session.MoveFile Method Problem

Problem's partly been solved.

Method works fine. I've just discovered that file was transfered. However I have to press Refresh button in both directories(remotePath, remotePath1) to see it.

So another question is how to refresh sesion automaticly after the transfer?

Re: .NET Assembly Session.MoveFile Method Problem

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

.NET Assembly Session.MoveFile Method Problem


I'm tring move zip files from one directory to another directory in the same server using by C#.
Despite app doesn't throw any erros, I can move those file, . I've red many articles but I haven't
found clear answer so far. Therefore I'm asking you for help. Below is a code:


SessionOptions sessionOptions = new SessionOptions
Protocol = Protocol.Sftp,
HostName = "",
UserName = "xxxxxxxxx",
Password= "xxxxxxxxx",
SshHostKeyFingerprint = "ssh-rsa xxx"
string fileName = "";
string remotePath = "/sftp/xxxx/xxxxxx/Test" + "/" + fileName;

//string remotePath1 = "/sftp/xxxx/xxxxxx/Test/Archive"; -> doesn't work
//string remotePath1 = "/sftp/xxxx/xxxxxx/Test/Archive" + "/"; -> doesn't work
string remotePath1 = "/sftp/xxxx/xxxxxx/Test/Archive" + "/" + fileName; // -> doesn't work

using (Session session = new Session())
Console.WriteLine("\nFrom here:\n{0}\nto here:\n{1}\n", remotePath, remotePath1);

if (session.FileExists(remotePath))
session.MoveFile(remotePath, remotePath1);

catch (Exception e)
Console.WriteLine("Error: {0}", e);

I guess It might be sth wrong with remotePath1, and I tred diferent combination of the remotePath1. Unfortunately, all of them failed. May be you have got better ideas?