All steps OK but not getting the files in .NET
I have a task to do SFTP in a .NET program. Everything is fine except that we are not getting back the files. In Debugging am not getting any errors in the steps but problem is no files coming back. in the manual SCP, we have to copy paste the files that come back, we wanted to automate this.
App.config
Program.cs
App.config
<appSettings> <add key="HostName" value="Groups.sftp.myhub.com" /> <add key="UserName" value="Groups" /> <add key="Password" value="mypassword" /> <add key="SshHostKeyFingerprint" value="ssh-rsa 2047 za:5z:z6:77:36:d6:94:89:44:15:b0:ca:59:bf:d3:92" /> <add key="LocalPath" value="\\server-app01\cust\SC\AMAZON\WINSCP\TESTAMAZON" /> <!-- this is local folder path --> <add key="RemotePath" value="/outgoing/orders/AMAZON/" /> <!-- this is remote system directory path --> <add key="ClientSettingsProvider.ServiceUri" value="" /> </appSettings>
// Setup session options SessionOptions sessionOptions = new SessionOptions { //Passing HostName , Password, & UserName here. port number Protocol = Protocol.Sftp, HostName = ConfigurationManager.AppSettings["HostName"].ToString(), UserName = ConfigurationManager.AppSettings["UserName"].ToString(), Password = ConfigurationManager.AppSettings["Password"].ToString(), SshHostKeyFingerprint = ConfigurationManager.AppSettings["SshHostKeyFingerprint"].ToString() }; string LocalPath = ConfigurationManager.AppSettings["LocalPath"].ToString(); string RemotePath = ConfigurationManager.AppSettings["RemotePath"].ToString(); using (Session session = new Session()) { // Connect session.Open(sessionOptions); // Upload files TransferOptions transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary; TransferOperationResult transferResult; transferResult = session.PutFiles(LocalPath + "*", RemotePath, false, transferOptions); // Throw on any error transferResult.Check(); }