Open session but don't upload files (C#)
I'm using C# and I need such logic:
Default .NET FileSystemWatcher is watching for new files in the folder.
As soon as new file is found in folder (it is also being checked if not locked) I need to open connection to SFTP server and upload that file.
I created method "Connect" which is just opening connection to SFTP with session.Open(sessionOptions). And another method "Upload" which checks session.Opened and if yes, uploads file. But this approach doesn't work.
So how to accomplish this?
By the way if I use example from your site:
Then this approach works, but if multiple files are being copied to the watching folder, WinSCP is creating SFTP connection on every file it uploads. I'm worried if that will be ok from SFTP server side.
Default .NET FileSystemWatcher is watching for new files in the folder.
As soon as new file is found in folder (it is also being checked if not locked) I need to open connection to SFTP server and upload that file.
I created method "Connect" which is just opening connection to SFTP with session.Open(sessionOptions). And another method "Upload" which checks session.Opened and if yes, uploads file. But this approach doesn't work.
So how to accomplish this?
By the way if I use example from your site:
SessionOptions sessionOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = "example.com", UserName = "user", Password = "mypassword", SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." }; using (Session session = new Session()) { // Connect session.Open(sessionOptions); ...................etc...etc...