So I have followed the documentation on the Xceed website, but I am not able to get my file to upload.
using( SSHClient ssh = new SSHClient() )
{
...
ssh.Connect( host );
...
ssh.Authenticate( username, password );
...
using( SFtpSession sftp = new SFtpSession( ssh ) )
{
AbstractFolder homeFolder = new SFtpFolder( sftp );
// Select a local file
AbstractFile localFile = new DiskFile( "D:\\SomeFile.dat" );
// Select a remote folder
AbstractFolder remoteFolder = new SFtpFolder( sftp, "SomeFolder" );
//Specify remote file name
AbstractFile remoteFile = sftpFolder.GetFile("RemoteFileName");
// Upload the local file to the remote folder
localFile.CopyTo( remoteFile , true );
}
}
When I try to upload a file, I get an exception.
Xceed.FileSystem.FileSystemException: SFtpFile: Can't represent '\SomeFolder\SomeFile.dat' as a file because it already exists as a 'SSH_FILEXFER_TYPE_DIRECTORY'.
Type: Xceed.SSH.Client.SFtpFolder
FullName: \SomeFolder\
at Xceed.SSH.Client.SFtpFile..ctor(SFtpSession session, String fullName)
at Xceed.SSH.Client.SFtpFolder.DoGetFile(FileSystemEventsSession session, String fileName)
at Xceed.FileSystem.AbstractFolder.GetFileFromRelativeName(FileSystemEventsSession session, String relativeName)
at Xceed.FileSystem.AbstractFolder.GetFile(FileSystemEvents events, Object userData, String relativeName)
I have tried looking around, but I can not seem to find anyone who has encountered this problem.