Access Files on Ubuntu Machine from windows in C#

Last Reply on Jul 28, 2016 12:10 AM By ShaibaazS

Posted on Jul 11, 2016 02:24 AM

I want to access Files on Ubuntu system from a window system. Both the systems are in the same network. Is there a way to achieve the above using c#


Posted on Jul 13, 2016 06:57 AM

Dear Dharmendr,

I have already gone through the links before and are not much of a use in my case.

But above all i really appreciate your help & support.



Posted on Jul 25, 2016 06:01 AM

Dear All,


I have achieved the same by using SFTP instead of FTP .

I dont know why it was not happening using FTP .

But through SFTP I achieved it.


Posted on Jul 25, 2016 06:32 AM

Hi ShaibaazS,

As you have solved by your self, so please share the solution with us so this can be beneficial to other community members reading the thread.

Posted on Jul 28, 2016 12:10 AM Modified on on Jul 28, 2016 12:11 AM

Yes I will be posting the answer .

For time being for whom ever who comes accross this situation

  1. Configure a SFTP Server on Ubuntu Machine.
  2. 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.
  3. 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;
  4. Also I have referred to the follwing Link:
  5. 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 = "";
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))
    using (var file = File.OpenWrite(LocalDestinationFilename))
        sftp.DownloadFile(RemoteFileName, file);

I hope this will help you.


Thanks .