Hi Everyone,
I need help from you guys, I thanks in advance. Actually the problem is Iam running Windows Application using C#4.0 Visual Studio 2010 on Windows7 O.S.
In this Application i have a Function Uploadto FTP()below is my function
public int UploadFiletoFTP()
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "XXXXXXXXXX",
UserName = "XXXXXXXXX",
Password = "XXXXXXXXX",
SshHostKeyFingerprint = "ssh-rsa XXXXXXXXXXX"
};
using (Session session = new Session())
{
// Connect
Common.Errlog("Connecting to the FTP.....");
session.Open(sessionOptions);
Common.Errlog("Connection to the FTP successfull....");
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
Common.Errlog("Fetching File from file system......");
transferResult = session.PutFiles(@filepathofCSVFile + TodaysDate + ".csv", "/home/tradein/", false, transferOptions);
// Throw on any error
transferResult.Check();
// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}
}
}
Iam getting Error at session.Open(sessionOptions); In this function iam trying to upload a function a CSV file to SFTP Server.
Note: That Server is SFTP.
Thanks,
Dinesh.