Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Im using below code to connect to an ftp server.

I get the exception Host not found.

VB
imports fluentftp
Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            Using Client As New FtpClient("server")
                Client.Credentials = New NetworkCredential(usename, password)
                Client.Connect()
                Client.UploadFile("test.txt", "STOR", "C:\!Temp\test.txt")
                MessageBox.Show("sent textfile")
            End Using
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub


What I have tried:

Search the whole net could not find any working code for VB.net.
Used framework 4.6 up to 4.8
Posted
Updated 25-Jan-20 6:07am
v3
Comments
Richard MacCutchan 25-Jan-20 12:22pm    
"server" does not look like a valid host name.
Dave Kreskowiak 25-Jan-20 13:28pm    
If you think you're going to just copy'n'paste code from the internet and expect it to magically work, you're not teaching yourself the correct way. Try reading the code you find, then looking up what each class and statement does, like "FtpClient".
Brollie 25-Jan-20 17:44pm    
Changed the server to the ipaddress. Now i get the exception Sorry, cleartext sessions and weak ciphers are not accepted on this server.; Please reconnect using TLS security mechanisms.
Richard Deeming 28-Jan-20 15:19pm    
Which would suggest that you need to connect using FTPS, as explained in the FluentFTP FAQ:
How do I connect with SSL/TLS? / How do I use FTPS?[^]

1 solution

The constructor of the FtpClient class probably expects either the server name or an IP address.
VB
Using Client As New FtpClient("server")

Try changing the "server" literal to the IP address of the server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900