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

Advertisement

dyankovich
Joined:
Posts:
1

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);
}

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum