Yes I will be posting the answer .
For time being for whom ever who comes accross this situation
- Configure a SFTP Server on Ubuntu Machine.
- In my case I have mapped Local IP to a Static IP for the Ubuntu machine by forwarding port "22" on my router. Port "22" is the default port for configuring SFTP Server.
- I have added "Renci.SshNet" reference from NuGet Packet Manager. For I have to add the following namesapces.
using Renci.SshNet;
using Renci.SshNet.Common;
using Renci.SshNet.Sftp;
- Also I have referred to the follwing Link: http://www.csidata.com/?page_id=2828
- Please find the below Source Code for the same.
using System.IO;
using Renci.SshNet;
using Renci.SshNet.Common;
using Renci.SshNet.Sftp;
String Host = "ftp.csidata.com";
int Port = 22;
String RemoteFileName = "TheDataFile.txt";
String LocalDestinationFilename = "TheDataFile.txt";
String Username = "yourusername";
String Password = "yourpassword";
using (var sftp = new SftpClient(Host, Port, Username, Password))
{
sftp.Connect();
using (var file = File.OpenWrite(LocalDestinationFilename))
{
sftp.DownloadFile(RemoteFileName, file);
}
sftp.Disconnect();
}
I hope this will help you.
Thanks .