1
I’m having a problem that’s turning my head backwards! I’m building a server connection DLL FTP but right away I’m faced with the following problem:
I need to declare the class in a form to open the connection to the Server FTP, but in this class declaration the variable has to contain the Ftpserv , User and Password. But there’s the problem. I can’t create string for a class, I have time programming but in javascript for games!
Example:
Imports Servidor.FTP
Dim FTPServ As New FTP("Servidor", "Usuário" , "Senha")
But the visual Studio says the following
Too Many Arguments to "Public Sub New"
I declared the Hostname, User and Password Property and I used Sub New but nothing right.
Initial Code of the DLL
Imports System.IO
Imports System.Net
Imports System.Net.NetworkCredential
Public Class FTPServ
    Dim URIFTP As String = ""
    Dim SWServidor As WebRequest = FtpWebRequest.Create(URIFTP)
    Public _Host As String
    Public _Password As String
    Public _User As String
    Public Property HostnameP As String
        Get
            Return _Host
        End Get
        Set(ByVal V As String)
        End Set
    End Property
    Public Property UsuárioP As String
        Get
            Return _Host
        End Get
        Set(ByVal V As String)
        End Set
    End Property
    Public Property SenhaP As String
        Get
            Return _Password
        End Get
        Set(ByVal V As String)
        End Set
    End Property
    Public Sub New(ByVal usuário As String, ByVal Senha As String, ByVal Domain As String)
        Me._Host = Domain
        Me._Password = Senha
        Me._User = usuário
    End Sub
    Public Function UploadFile(ByVal URLArquivo As String, Destino As String)
        ' SWServidor.Credentials = New NetworkCredential(Hostname, Usuário, Senha)
        SWServidor.Method = WebRequestMethods.Ftp.UploadFile
        Try
            Dim ByteFile() As Byte = System.IO.File.ReadAllBytes(Destino)
            Dim MyStream As System.IO.Stream = SWServidor.GetRequestStream()
            MyStream.Write(ByteFile, 0, ByteFile.Length)
            MyStream.Close()
            MyStream.Dispose()
        Catch ex As Exception
            MsgBox("Erro")
        End Try
    End Function
End Class
Syntax is wrong. What type of must be the variable
FTPServ? Do you have any documentation of this class? It would be nice to see the builder of this type to see if it is matching what you are using. Without seeing how she is There’s no way to answer.– Maniero
Parameters passed in class creation do not match with constructor.
– rubStackOverflow
Ftpserv is a reference to FTP class and this FTP class has to get these user and password server parameters
– Vyctor Junior
Put the FTP class constructor code there.
– rubStackOverflow
take a look there I’ve done several ways but at the time of declaring the variable in the form VS still says Too Many Arguments
– Vyctor Junior
Good afternoon, managed to solve the problem?
– Guilherme Nascimento