7 Replies - 352 Views - Last Post: 08 February 2020 - 01:28 AM Rate Topic: -----

#1 aspfun   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 135
  • Joined: 16-January 13

How to code to upload files to FTP server?

Posted 06 February 2020 - 02:18 PM

For Winform project how to code to upload files to FTP server?
Does need third party library?
Is This A Good Question/Topic? 0
  • +

Replies To: How to code to upload files to FTP server?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: How to code to upload files to FTP server?

Posted 06 February 2020 - 02:38 PM

Webclient Uploadfile is typically the most direct.
https://docs.microso...etframework-4.8
Was This Post Helpful? 0
  • +
  • -

#3 aspfun   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 135
  • Joined: 16-January 13

Re: How to code to upload files to FTP server?

Posted 07 February 2020 - 07:20 AM

View Postmodi123_1, on 06 February 2020 - 02:38 PM, said:

Webclient Uploadfile is typically the most direct.
https://docs.microso...etframework-4.8


The project I created is using SSH.NET and it works fine for two years.

But, after Windows update it did not work anymore.

The error message is: Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: How to code to upload files to FTP server?

Posted 07 February 2020 - 08:10 AM

Totes good information to know up front.

I would have to see the full error message and the relevant code.
Was This Post Helpful? 0
  • +
  • -

#5 aspfun   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 135
  • Joined: 16-January 13

Re: How to code to upload files to FTP server?

Posted 07 February 2020 - 08:14 AM

View Postmodi123_1, on 07 February 2020 - 08:10 AM, said:

Totes good information to know up front.

I would have to see the full error message and the relevant code.


Error in Sub AllStepsNew ---2020-02-06 17:52:01---Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()

 Private Sub UploadSFTPFile(ByVal host As String, ByVal username As String, ByVal password As String, ByVal port As Integer, ByVal sourcefile As String, ByVal destinationpath As String)
        Dim client As SftpClient = New SftpClient(host, port, username, password)
        client.Connect()
        client.ChangeDirectory(destinationpath)
        Dim fs As FileStream = New FileStream(sourcefile, FileMode.Open)
        client.BufferSize = (4 * 1024)
        client.UploadFile(fs, Path.GetFileName(sourcefile))
    End Sub


Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: How to code to upload files to FTP server?

Posted 07 February 2020 - 08:20 AM

Have you tried increasing the timeouts by increments of 10 to about a minute or two?

Flip to a different port # maybe?
Was This Post Helpful? 0
  • +
  • -

#7 aspfun   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 135
  • Joined: 16-January 13

Re: How to code to upload files to FTP server?

Posted 07 February 2020 - 09:00 AM

View Postmodi123_1, on 07 February 2020 - 08:20 AM, said:

Have you tried increasing the timeouts by increments of 10 to about a minute or two?

Flip to a different port # maybe?


Port is fixed because ftp server can't change port #.
Test ftp server is using port 1022 and real ftp server is using 22.
For ftp server, there is no any issue.
Was This Post Helpful? 0
  • +
  • -

#8 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 394
  • View blog
  • Posts: 1,648
  • Joined: 07-September 13

Re: How to code to upload files to FTP server?

Posted 08 February 2020 - 01:28 AM

Sounds ridiculous, but if its been working for so long, have you made sure the password and host is up to date?

If your using the host name, try switching to IP, wondering if the DNS has gotten in a tizzle and lost some hostnames, we have that problem with our VM's some of them we can only connect to via ip's?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1