Topic "All steps OK but not getting the files in .net"

Author Message
Pimhach
[View user's profile]

Joined: 2015-11-23
Posts: 1
Location: New Jersey
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

<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>
Program.cs try { // 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();
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Your duplicate post on Stack Overflow:
http://stackoverflow.com/q/33882043/850848
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License