Posts

Showing posts with the label SSH.NET

Donate

Append Text To Textfile In FTP Or SFTP Using SSH.NET

Hello, FtpWebRequest in .NET has few dozen bugs and some limitations when communicating to an FTP or perhaps an SFTP server. So, I decided to use SSH.NET which is a 3rd party .NET FTP client. You can use WinSCP or other existing FTP clients out there. Here's a sample code to append text to a textfile located in an FTP or SFTP Server. private void AppendTextToTextFile() { const int port = 22; const string host = "192.168.2.1" ; const string username = "greg" ; const string password = "testpassword" ; const string workingdirectory = "/root/files" ; const string uploadfile = @"D:\uploadfile.txt" ; Console.WriteLine( "Creating client and connecting" ); try { using ( var client = new SftpClient(host, port, username, password)) { client.Connect(); Console.WriteLine( "Con

Donate