Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
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)

Options

Topic review

dyankovich

Copying files to remote side failed, Could not change to "/ftp:/"; 'ftp:' not found

I continually get this error on the line of code noted below what could I be doing wrong? thank you all for everything!!!

{WinSCP.SessionRemoteException: Error transferring file '@"C:file\filename.txt"'. ---> WinSCP.SessionRemoteException: Copying files to remote side failed.
Could not change to "/ftp:/"; 'ftp:' not found.
--- End of inner exception stack trace ---
at WinSCP.OperationResultBase.Check()



<appSettings>
<add key="FTPUrl" value="ftp://host.com/folder%20-%to%20uploadto/"/>
<add key="FTPUser" value="domain/username"/>
<add key="FTPPass" value="password"/>
<add key="FTPDomain" value="domain"/>
</appSettings>

private static void transferWinSCP()
{
string userName = ConfigurationManager.AppSettings["FTPUser"];
string password = ConfigurationManager.AppSettings["FTPPass"];
string url = ConfigurationManager.AppSettings["FTPUrl"];
try
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "hostname.com",
PortNumber = 990,
UserName = userName,
Password = password,
FtpSecure = FtpSecure.Implicit,
FtpMode = FtpMode.Passive,
TlsHostCertificateFingerprint = "xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
};

using (Session session = new Session())
{
//connect
session.Open(sessionOptions);

//upload
TransferOptions transferOptions = new TransferOptions {TransferMode = TransferMode.Binary};

TransferOperationResult transferResult = session.PutFiles(@"C:file\filename.txt",url, false,
transferOptions);
I get the error on this line

transferResult.Check(); //ftp error

foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.Write("upload of {0} succeeded", transfer.FileName);
}


}

}
catch (Exception ex)
{
Console.Write("error {0}", ex);
}